Joel de Guzman
I think Jens got it incorrectly. The var will *not* be created at all on an unsuccessful match.
Which is cool, but misses my point. Take the example again, but this time I have made a mistake: factor = ureal_p[factor.val = arg1] | '(' >> expression[factor.val = arg1] >> ')' | ('-' >> factor) | ('+' >> factor[factor.val = arg1]) ; In the third branch, I forgot to assign something. It will compile, though it better should not - the parsed return value is bogus. How do I prevent such bugs? Hand-written parsers can be written in such a safe way: optional< value_t > factor(tokens_t tokens) { // value_t is not default constructible if(optional< value_t > temp = ureal_p(tokens)) return temp; else if(optional< value_t > temp = expression(tokens)) return temp; else ... return none; } How to do it with spirit? Regards, Jens