
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 ; }; template < class Head
struct or_op < Head , or_base
{ typedef Head type ; }; typedef mpl::vector < inp<inp_0>::type , inp<inp_1>::type , out<out_0>::type , out<out_1>::type , out<out_2>::type
grm_syms ; struct grm_symbol : mpl::fold < grm_syms , or_base , or_op < mpl::arg<2> , mpl::arg<1> >
::type { };
And it appears to work.