Closed akrzemi1 closed 6 months ago
Don't be sorry! I appreciate the early review. I'll investigate this this weekend.
Even worse, this also does not work:
#include <boost/parser/parser.hpp>
#include <vector>
struct X {
char a;
int b;
};
struct SimplerY {
X x;
int c;
};
int main()
{
namespace bp = boost::parser;
auto parse_x = bp::char_ >> bp::int_;
auto parse_y = parse_x >> bp::int_;
SimplerY y;
auto b = bp::parse("d 3 4", parse_y, bp::ws, y);
}
I have some work to do it seems.
Ok, after thinking about this a bit, there's no bug with my "simplified" case above. When you write parse_x >> bp::int_
as the definition of parse_y
, the sequence-parser parse_x
combines with bp::int_
, just as if you wrote it all on the same line. IOW, parse_y
is equivalent to bp::char_ >> bp::int_ >> bp::int_
. When you then try to parse that into an object of type Y
, it has to map the three elements the parse expects onto the two data members of `Y.
Correct. Boost.Spirit also rejects your simplified example.
Sorry, one more. The following case where we have an indirectly nested aggregate doesn't compile:
The Boost.Spirit analogue compiles fine: