Boost logo

Boost :

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


On 09/18/13 22:46, Matt Calabrese wrote:
> On Wed, Sep 18, 2013 at 7:14 PM, Daryle Walker <darylew_at_[hidden]> wrote:
>
>> I would go the other way and start support from zero arguments! The "and"
>> operation would default to TRUE while "or" defaults to "FALSE." (Hint: the
>> operations default to their "identity" operand value, and definitely not
>> their "short-circuit" operand value.)
>>
>
> I agree. Use of that kind of stuff comes up all the time when dealing with
> variadics. Having sensible 0 argument and 1 argument forms is important.
>
My reply to Augustin mentioned a variadic and_ and or_ which takes
any number of args, including 0. I looked closer at the code and found:

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

which is used, indirectly, by the and_ and or_ metafunctions. The
null_unit comments indicates it short-circuits the evaluation
based on whether the current argument is the Null argument.
In the case of and_, Null would be mpl::false_,
In the case of or_, Null would be mpl::true_.

At least that's my understanding after a brief review of code.

HTH.
-regards,
Larry


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