Boost logo

Boost :

Subject: Re: [boost] [mpl] and_<true_> returns false
From: Larry Evans (cppljevans_at_[hidden])
Date: 2013-09-19 10:25:53


On 09/18/13 18:33, Agustín K-ballo Bergé wrote:
> The following snippet fails to compile (tested with 1.54.0 and trunk,
> several compilers),
>
> #include <boost/mpl/and.hpp>
> #include <boost/mpl/bool.hpp>
> #include <boost/mpl/or.hpp>
>
> int main() {
> using namespace boost::mpl;
> static_assert(and_<true_>::value, "U KID?"); //this one fires
> static_assert(or_<true_>::value, "U KID?"); //this one is ok
> }
>
> This issue actually showed up in a variadic template scenario. Is this a
> bug? I feel like I'm doing something really wrong...
>
> I guess one may not call `and_` with less than two arguments. If that's
> the case, it would be helpful if it would be impossible to instantiate
> it with a single argument.
>
> Regards,

There's a variadic mpl::and_ and mpl::or_ which I think solves
this problem. However, I seriously doubt it would compile
as fast because, my impression is that the standard boost mpl
spent a lot of effort using the preprocessor to speed compile
times, and the variadic versions here:

http://svn.boost.org/svn/boost/sandbox/variadic_templates/boost/mpl/

were not coded with compile speed in mind :(

-regards
Larry


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