I have an AST element defined roughly as
struct Something
{
boost::optional<string> foo;
string bar;
}
in my parsing code, I parse it as
-(identifier >> ':')
>> type
Now, here's the problem: if I feed the parser the string hello:world
, everything works correctly, i.e.,
foo = hello
bar = world
If, however, I feed the parser the string hello
, I get
foo = hello
bar = hello
whereas what I want is
foo = boost::optional<string>()
bar = hello
How can I achieve this in Boost.Spirit?