Boost logo

Boost :

From: Maurizio Vitale (mav_at_[hidden])
Date: 2007-04-17 05:19:19


The following fragments show what I think are the relevant parts of a file (which I can post if
this doesn't explain the situation).

For what I can tell, it is not too different from the lazy_vector example included with the documentation.
I'd expect my_int<2> to match the grammar, but it doesn't.

If I add proto::terminal<number<proto::_,proto::_> > as another term to the or, then I get a match.
So it seems like the problem is with the "partial specialization" on two_complement_c and magnitude_c.
Is there anything I have to do to them to make tham more "patternish".

Thanks,
        Maurizio

enum binary_representation_enum {magnitude, two_complement};
typedef mpl::integral_c<binary_representation_enum, magnitude> magnitude_c;
typedef mpl::integral_c<binary_representation_enum, two_complement> two_complement_c;

struct grammar : proto::or_ <
  proto::terminal<number<proto::_, two_complement_c> > ,
  proto::terminal<number<proto::_, magnitude_c> >
>
{};

template<int N>
struct my_int : my_expr<typename proto::terminal<number<mpl::int_<N>, two_complement_c > >::type>
{
...
};

template<typename Expr>
void test (const Expr& expr) {
  if (proto::matches<Expr, grammar>::value)
    std::cout << "matches grammar\n\n";
  else
    std::cout << "doesn't matches grammar\n\n";
}

my_int<2> i2;
test (i2);


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk