
"Kim Kuen Tang"
I see that this is a problem. (What does UB stand for?)
UB = Undefined Behavior (the compiler can crash, produce wrong results, or anything else)
But can a correct implemented grammar be a workaround?
The grammar was correct, but it was given an invald expression (that sort-of looked valid).
Perhaps we can first check whether var1_ appears in the expression. If not we can return the expression unmodified.
The way to check if the expression is valid for a grammar is something like the code below. I'm hoping Eric can automatically do this check when a compile-time debug flag is defined. Regards, Dave Jenkins template< typename Expr > void Solve_check( Expr const & expr ) { if ( !proto::matches< Expr, Solve >::value ) { std::cout << "Expression does not match grammar\n\n"; } } int main() { Solve_check(var_ + 1 = 2); proto::display_expr( var_ + 1 = 2 ); proto::display_expr( Solve()( var_ + 1 = 2 ) ); }