Boost logo

Boost :

Subject: Re: [boost] [mpl] is there a or_seq like logical metafunction?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2009-02-08 08:50:05


On 02/07/09 13:58, Larry Evans wrote:
> On 02/07/09 13:29, vicente.botet wrote:
[snip]
>> After suggestion of I don't remember who, I have implemented it as
>>
>> /* Calculate the mlp::and_ of a sequence of nullary logical
>> metafunctions.*/ template <typename Seq>
>> struct and_seq : boost::is_same<typename mpl::find_if<Seq,
>> mpl::not_<mpl::_> >::type, typename mpl::end<Seq>::type>
>> {};
> [snip]
>>
>> If there are better ways to do that, you don't tink that this must be
>> encapsulated in the library? Why not add these metafunctions in
>> Boost.MPL?
>>
>> Thanks,
>
> OOPS. I misread the post. I was just thinking of and_ and or_.
> I missed the "sequence of nullary logical metafunctions".
> Sorry for noise. It just seemed so similar I neglected
> any differences.

Aren't true_ and false_ nullary logical metafunctions. If
so then I think what you're requiring is someway to
"unpack" the args from Seq<T1,T2,...Tn> into and_<T1,T2,...,Tn>
or or_<T1,T2,...,Tn>. Could:

http://www.boost.org/doc/libs/1_37_0/libs/mpl/doc/refmanual/unpack-args.html

be used to do that? If not, then it's pretty easy to do that
with the variadic version of mpl since all Sequences are
derived from package<T1,T2,...,Tn> so:

   template<typename... T>
   or_seq<package<T...> >
   : or_<T...>
   {};

A prototype variadic version of mpl is in the boost vault.


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