BOOST_FUSION_ADAPT_STRUCT does not accept the correct number of arguments

I use Boost :: Spirit to parse text in structures. To do this, use BOOST_FUSION_ADAPT_STRUCT for text analysis and direct storage in the structure. I know that a macro takes 2 arguments: the name of the structure as the 1st argument and all members of the structure as the 2nd argument. And I only pass those 2. But I get a compilation error saying:

error: macro "BOOST_FUSION_ADAPT_STRUCT_FILLER_0" passed 3 arguments, but takes just 2 

Here is a snippet of code. Let me know if you need all the code.

Thanks.

 namespace client { namespace qi = boost::spirit::qi; namespace ascii = boost::spirit::ascii; namespace phoenix = boost::phoenix; struct Dir_Entry_Pair { std::string dir; std::string value1; std::pair<std::string, std::string> keyw_value2; }; } BOOST_FUSION_ADAPT_STRUCT( client::Dir_Entry_Pair, (std::string, dir) (std::string, value1) (std::pair< std::string, std::string >, keyw_value2)) 

This is the rule I'm trying to analyze,

 qi::rule<Iterator, Dir_Entry_Pair()> ppair = dir >> '/' >> entry >> -(keyword >> entry); 
+7
source share
1 answer

Most likely the problem is: std::pair<std::string,std::string> .

The problem is that there is a comma in the type that will play chaos with the macro extension (when using the last element of your list).

You should try wrapping the type in your own set of parentheses.

+10
source

All Articles