Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2008-03-28 17:19:55


Steven Watanabe wrote:
> Eric Niebler wrote:
>> Consider:
>>
>> and_<
>> when<G1, T1>
>> ,when<G2, T2>
>> >
>>
>> T1 requires that any expression passed to it matches G1. Likewise for T2
>> and G2. Now, imagine that the result of applying T1 is some type that
>> *doesn't* match G2 ... it might not even be an expression! If you tried
>> to pass it to T2, you would be violating T2's preconditions. T2's
>> transform will likely fail.
>
> How about passing it the _state parameter?

So that and_'s transform works a bit like fold? That's an interesting
suggestion. Can you give me a use case?

The times I've needed and_ in my grammar, it's looked like:

   and_<
     terminal<_>
    ,if_<is_base_of<MyBase,_arg>() >
>

or something. In this case, passing the _state parameter to terminal<>'s
transform would violate its preconditions (it expects a terminal
expression), so this might not be such a great idea.

Today, this transform isn't terribly interesting ... it just returns the
terminal expression unmodified.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

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