Boost logo

Boost :

Subject: Re: [boost] [proto] Problems with operator <<
From: John Maddock (boost.regex_at_[hidden])
Date: 2011-08-26 03:32:51


>> BTW I do specify a proto grammar, and only enable the operators I need
>> on a case by case basis, in this case though I would need to restrict
>> the grammar so that proto's shift operators are only enabled for RHS
>> arguments of integer type. Is that possible?
>
> Yes. Can you post your grammar?

Pretty basic at present, need to refine those terminals a bit more! :

struct big_number_grammar
  : proto::or_<
        proto::terminal< proto::_ >
      , proto::plus< big_number_grammar, big_number_grammar >
      , proto::multiplies< big_number_grammar, big_number_grammar >
      , proto::minus< big_number_grammar, big_number_grammar >
      , proto::divides< big_number_grammar, big_number_grammar >
      , proto::unary_plus< big_number_grammar >
      , proto::negate< big_number_grammar >
      , proto::modulus<big_number_grammar, big_number_grammar>
      , proto::shift_left<big_number_grammar, big_number_grammar>
      , proto::shift_right<big_number_grammar, big_number_grammar>
>
{};

I assume I could replace

      , proto::shift_right<big_number_grammar, big_number_grammar>

with something like:

      , proto::shift_right<big_number_grammar, integer_terminal>

Where integer_terminal is a big list of terminal integer types, but is there
any way to use a predicate to say "any type that matches predicate X is a
terminal"?

Thanks, John.


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