
David Abrahams wrote:
Jens Theisen
writes: I'm not complaining that `factor' must have been default constructed. I'm worrying about the return value, which is represented by the `val' closure member. The point where we know what to return is where the assignments are, but by design we must have some value earlier than that.
Ah, I understand.
I think Jens got it incorrectly. The var will *not* be created at all on an unsuccessful match. No, the value is not created prior to entering the rule. The value is created *lazily* after, and only after, a successful match is made. That's the beauty of lazy evaluation. Don't be misled by the syntax. On a no-match, the result is an optional<T>(), like in your example. See match class in match.hpp and notice the optional_type val; that's your attribute. Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net