
On 02/10/09 12:45, vicente.botet wrote:
----- Original Message ----- From: "Larry Evans" <cppljevans@suddenlink.net> To: <boost@lists.boost.org> Sent: Sunday, February 08, 2009 2:50 PM Subject: Re: [boost] [mpl] is there a or_seq like logical metafunction? [snip]
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?
Oh! this is quite interesting. I will try it to see how it works. WHich implementation should perdorms better if any difference?
I don't know. I assume you mean the two methods: 1) find_if a true_ or false_ 2) unpack then use and_ or or_ If you're using the variadic compiler, then the 2nd would work faster because the unpacking is done by the compiler instead of by template metaprogramming. If not, then I really don't know because I've not looked at the unpack code.
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.
Thanks for the pointer,
You're most welcome. BTW, what about the while_ template mentioned in my other recent post. It seems that would be most general, and it just uses template recursion and eval_if. If simplified implementation *usually* means faster execution, then maybe while_ would be fastest. I know the non-variadic and_ uses recursion (as I mentioned in my reply to David), so; I don't think that would be a disadvantage. -Regards, Larry