Boost logo

Boost :

Subject: Re: [boost] [mpl] is there a or_seq like logical metafunction?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-02-15 14:29:59


AMDG

Larry Evans wrote:
>> This "optimization" was ineffective. There were
>> 303 instantiations vs. the 297 in the original
>> version :( .
>
> Changing equal to is_same (and making adjustments to where
> ::type is placed) resulted in just 185 instantiations!

If you really must optimize this to death...

#include <boost/mpl/next.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/begin.hpp>
#include <boost/mpl/end.hpp>
#include <boost/mpl/and.hpp>
/* Calculate the mpl::and_ of a sequence of nullary logical
metafunctions.*/

template<class Begin, class End>
struct and_iter : boost::mpl::and_<
    typename boost::mpl::deref<Begin>::type,
    and_iter<typename boost::mpl::next<Begin>::type, End>
> {};

template<class End>
struct and_iter<End, End> : boost::mpl::false_ {};

template <typename Seq>
struct and_seq : and_iter<typename boost::mpl::begin<Seq>::type,
typename boost::mpl::end<Seq>::type> {};
 
#include <and_seq_instances.hpp>

In Christ,
Steven Watanabe


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