
Larry Evans wrote:
Just as:
terminal<X>:;type
is the type of expressions matching the grammar, terminal<X>, I would expect that binary_expr<T,L,R>::type would match binary_expr<T,L,R>. IOW, just as:
matches<terminal<X>::type,terminal<X> >
is true, should:
matches<binary_expr<T,L,R>::type,binary_expr<T,L,R> >
be true?
That is the intention, yes. More specifically, binary_expr<X,Y,Z> matches binary_expr<A,B,C>::type when Y matches B, Z matches C, and X is A or proto::_.
If not, then what is the purpose of binary_expr<,,>::type? If yes, then why am I getting an error with the attached driver whose compilation output is also attached?
Your problem distills down to: typedef terminal<x> GX; // grammar for x typedef GX::type EX; // expression for x typedef shift_right<GX, GX> SRGX; // grammar for x>>x typedef SRGX::type SREX; // OOPS! You then try to use SREX as a valid expression type, and it is not. It should be: typedef shift_right<EX, EX>::type SREX; The difference is that in the first case, you're creating the type of a right shift expression where the operands are grammars. You really want the operands to be expression types. HTH, -- Eric Niebler Boost Consulting www.boost-consulting.com