Example parsing error

后端 未结 1 653
借酒劲吻你
借酒劲吻你 2020-12-12 02:44

I\'m trying to parse an example of boost spirit (2.5.2) following the example. My code is the following

#include 
#include         


        
1条回答
  •  借酒劲吻你
    2020-12-12 03:23

    You are missing an include:

    #include 
    

    It defines the attribute assignment rules to make Fusion sequences (vector2<>) assignable to std::pair.

    See the code live: liveworkspace.org

    #include 
    #include 
    #include 
    #include 
    #include 
    
    int main()
    {
        // Parsing two numbers
        std::string input("1.2 3.4");
        std::pair p;
    
        namespace qi = boost::spirit::qi;
    
        qi::phrase_parse(
                input.begin(), 
                input.end(),
                qi::double_ >> qi::double_ , // Parse grammar
                qi::space, p);
    
        std::cout << "Lo:     " << p.first << "\n"
                  << "Behold: " << p.second << "\n";
    }
    

    0 讨论(0)
提交回复
热议问题