#include #include #include #include namespace qi = boost::spirit::qi; struct test { int a; char b; }; BOOST_FUSION_ADAPT_STRUCT( test , (int, a) (char, b) ) template void test_parser_attr( char const* input, P const& p, T& attr, bool full_match = true) { using boost::spirit::qi::parse; char const* f(input); char const* l(f + strlen(f)); if (parse(f, l, p, attr) && (!full_match || (f == l))) std::cout << "ok" << std::endl; else std::cout << "fail" << std::endl; } int main( int argc, char** argv ) { boost::fusion::vector< int, char > ft; test_parser_attr( "64c128.0", qi::int_ > qi::char_ > qi::float_, ft ); test st; test_parser_attr( "64c128.0", qi::int_ > qi::char_ > qi::float_, st ); test_parser_attr( "64c128.0", qi::as< test >()[ qi::int_ > qi::char_ > qi::float_ ], st ); return 0; }