#include <boost/parser/parser.hpp>
#include <vector>
struct X
{
char a;
int b;
};
int main()
{
namespace bp = boost::parser;
auto pair = bp::char_ >> bp::int_;
auto pairs = +pair;
std::vector<X> x;
auto b = bp::parse("d 3", pairs, bp::ws, x);
}
The analogous code in Boost.Spirit works:
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
#include <boost/spirit/include/qi.hpp>
struct X
{
char a;
int b;
};
BOOST_FUSION_ADAPT_STRUCT(X, a, b);
int main()
{
namespace bp = boost::spirit::qi;
auto pair = bp::char_ >> bp::int_;
auto pairs = +pair;
std::vector<X> x;
std::string input = "d 3 c 4";
auto begin = input.begin();
bool b = bp::phrase_parse(begin, input.end(), pairs, bp::ascii::space, x);
}
While https://github.com/tzlaine/parser/issues/28 fixes the parsing into a single aggregate, parsing to a vector of aggregates still doesn't work.
The following fails to compile.
The analogous code in Boost.Spirit works: