Re: [Boost-bugs] [Boost C++ Libraries] #13093: boost_1_41_0 and qi compiler error

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #13093: boost_1_41_0 and qi compiler error
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-06-23 17:17:54


#13093: boost_1_41_0 and qi compiler error
-------------------------------+---------------------
  Reporter: anonymous | Owner: djowel
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: spirit
   Version: Boost 1.41.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+---------------------

Comment (by anonymous):

 {{{
 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]'

 }}}

--
Ticket URL: <https://svn.boost.org/trac10/boost/ticket/13093#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-06-23 17:39:24 UTC