Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2008-03-02 20:56:40

On 03/02/08 19:39, Eric Niebler wrote:
> 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,
Yes, thanks. I had actually concluded that, but then thought,
in that case, the shift_right template arguments can be either
grammar types or expression types and, depending on which they
are, the nested type may or may not make sense. That kinda
bothered me because it was confusing. Someone reading the
code would have to realize this to avoid confusion.

Here's actually part of what I had written before sent my post:

     b) operator expressions

        For each operator grammar instance (see above), O_inst, there's
        the corresponding type of expressions which match that grammar.
        For example, if:

                 < T0
                 , T1
                 , ...
                 , Tn
                 < T0::type
                 , T1::type
                 , ...
                 , Tn::type



        OOPS. This doesn't make sense either because in one instance
        the the template args are grammar types and in the 2nd they're
        expressiont types. Looking at traits.hpp shows:

             template<typename Tag, typename T, typename U>
             struct binary_expr : pass_through<binary_expr<Tag, T, U> >
                 typedef proto::expr<Tag, args2<T, U> > type;
                 typedef type proto_base_expr;
                 typedef Tag proto_tag;
                 typedef T proto_arg0;
                 typedef U proto_arg1;

        so the subexpression types are grammar types?

I'd be more comfortable if the validity of the nested type
didn't depend on particular type of the template parameter.

Boost list run by bdawes at, gregod at, cpdaniel at, john at