Opened 5 years ago

Closed 5 years ago

#13093 closed Bugs (fixed)

boost_1_41_0 and qi compiler error

Reported by: anonymous Owned by: Joel de Guzman
Milestone: To Be Determined Component: spirit
Version: Boost 1.41.0 Severity: Problem
Keywords: Cc:

Description

Does anyone know how to fix the following errors? They are the same type and come up with 1_41 version. whereas with 1_53, it just compiles and run fine.

I need this to worked with 1_41. The code and detail files are attached.

1) rule.cpp:36:14: required from ‘json::Grammar<Iterator>::Grammar() [with Iterator = gnu_cxx::normal_iterator<const char*, std::basic_string<char> >]’ rule.cpp:54:47: required from here ./boost_1_41_0/boost/spirit/home/support/attributes.hpp:409:70: error: no matching function for call to ‘std::map<std::basic_string<char>, boost::any>::map(boost::any&)’

static Transformed pre(Exposed& val) { return Transformed(val); }

2) rule.cpp:36:14: required from ‘json::Grammar<Iterator>::Grammar() [with Iterator = gnu_cxx::normal_iterator<const char*, std::basic_string<char> >]’ rule.cpp:54:47: required from here ./boost_1_41_0/boost/spirit/home/support/attributes.hpp:409:70: error: no matching function for call to ‘std::vector<boost::any>::vector(boost::any&)’

static Transformed pre(Exposed& val) { return Transformed(val); }

3) rule.cpp:36:14: required from ‘json::Grammar<Iterator>::Grammar() [with Iterator = gnu_cxx::normal_iterator<const char*, std::basic_string<char> >]’ rule.cpp:54:47: required from here ./boost_1_41_0/boost/spirit/home/support/attributes.hpp:409:70: error: no matching function for call to ‘std::basic_string<char>::basic_string(boost::any&)’

static Transformed pre(Exposed& val) { return Transformed(val); }

Attachments (2)

rule.cpp (3.0 KB ) - added by anonymous 5 years ago.
report.log (129.9 KB ) - added by anonymous 5 years ago.

Download all attachments as: .zip

Change History (5)

by anonymous, 5 years ago

Attachment: rule.cpp added

by anonymous, 5 years ago

Attachment: report.log added

comment:1 by anonymous, 5 years ago

source code in case you dont want to download the cpp-
#include <boost/any.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/fusion/adapted/std_pair.hpp>
#include <boost/fusion/adapted/boost_tuple.hpp>

#include <vector>
#include <map>
#include <iostream>

namespace json {

namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;

struct nullptr_t_ : qi::symbols< char, void * > {
  nullptr_t_() {
    add( "null", NULL );
  }
} nullptr_;

typedef std::map<std::string, boost::any> map_any;
typedef std::vector<boost::any> vector_any;
typedef std::pair<std::string, boost::any> pair_any;

template< typename Iterator >
struct Grammar : qi::grammar< Iterator, boost::any(), ascii::space_type > {
Grammar(): Grammar::base_type( start ) {
    using qi::lexeme;
    using qi::double_;
    using qi::bool_;
    using ascii::char_;

    start = value_rule.alias();
    object_rule = '{' >> pair_rule % ',' >> '}';
    pair_rule = string_rule >> ':' >> value_rule;
    value_rule = object_rule | array_rule | string_rule | nullptr_ | double_ | bool_;
    array_rule = '[' >> value_rule % ',' >> ']';
    string_rule = lexeme[ '\"' >> *( char_ - '\"' ) >> '\"' ];
  }

  qi::rule<Iterator, boost::any(), ascii::space_type>   start;
  qi::rule<Iterator, map_any(), ascii::space_type>      object_rule;
  qi::rule<Iterator, pair_any(), ascii::space_type>     pair_rule;
  qi::rule<Iterator, boost::any(), ascii::space_type>   value_rule;
  qi::rule<Iterator, vector_any(), ascii::space_type>   array_rule;
  qi::rule<Iterator, std::string(), ascii::space_type>  string_rule;
};

}

int main(int argc, char** argv) {
  //"{\"name\":10}"
  const std::string source(argv[1]);
  json::Grammar< std::string::const_iterator > g;
  boost::any v;
  json::map_any ma;
  json::vector_any va;
  json::pair_any pa;
  std::string::const_iterator  bit = source.begin();
  std::string::const_iterator  eit = source.end();
  bool r = boost::spirit::qi::phrase_parse( bit, eit, g, boost::spirit::ascii::space, v );
  if( r ) {
    std::cout << BOOST_LIB_VERSION << std::endl;
    std::cout << v.type().name() << std::endl;
    std::cout << typeid(ma).name() << std::endl;
    std::cout << typeid(va).name() << std::endl;
    std::cout << typeid(pa).name() << std::endl;
    return 0;
    std::vector< boost::any> a = boost::any_cast< std::vector< boost::any> >( v );
    for( std::vector< boost::any>::iterator it = a.begin(); it != a.end(); ++it ) {
      if(it->type() == typeid(char*)) {
        std::cout << boost::any_cast< char*>( *it ) << std::endl;
      } else if(it->type() == typeid(const char*)) {
        std::cout << boost::any_cast< const char*>( *it ) << std::endl;
      } else if(it->type() == typeid(std::string)) {
        std::cout << boost::any_cast< std::string>( *it ) << std::endl;
      } else if(it->type() == typeid(double)) {
        std::cout << boost::any_cast< double>( *it ) << std::endl;
      } else if(it->type() == typeid(bool)) {
        std::cout << boost::any_cast< bool>( *it ) << std::endl;
      } else {
        std::cout << boost::any_cast< void * >( *it ) << std::endl;
      }
    }
  } else {
    std::cout << "not found" << std::endl;
  }
  return 0;
}

Build - 
g++ -g3 rule.cpp -I./boost_1_41_0 2>&1 | tee report.log

Run
./a.out '[1.0,2.0]'

comment:2 by Nikita Kniazev <nok.raven@…>, 5 years ago

Well, for this kind of questions I suppose no one except you will spend the time. If you really want to find the commit that fixed the problem you should use git bisect.

comment:3 by Joel de Guzman, 5 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.