|
Boost : |
From: Eric Niebler (eric_at_[hidden])
Date: 2007-04-19 12:46:18
Larry Evans wrote:
> On 04/18/2007 01:06 PM, Eric Niebler wrote:
>> Larry Evans wrote:
> [snip]
>>> I've just encounted a need for something like this. For example,
>>> if you have a list of types for which you want to apply the or_ to,
>>> however, that list must by calculated, then the only way to apply
>>> or to it is with a fold operation. Since mpl::fold takes
>>> an argument represening the initial state, this would naturally
>>> be proto::or_<> in case you want to proto::or_ together a list
>>> of types.
>> <snip>
>>
>> Interesting. In order for this to work, proto::or_ would need to be an
>> extensible mpl sequence, right?
> [snip]
>
> No. The input to fold has to be; however, the output produced doesn't.
> Here's what I've got so far:
>
> struct
> or_base
> ;
> template
> < class Head
> , class Tail
> >
> struct
> or_op
> {
> typedef
> proto::or_
> < Head
> , typename Tail::type
> >
> type
> ;
Oh! You're chaining or_'s together. Sure, that works. So for your
initial state, all you need is a pattern that never matches anything.
For that, you can use proto::not<proto::_>.
-- 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