Boost logo

Boost :

Subject: Re: [boost] SFINAE yes_type and no_type
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2011-04-16 16:24:03


Edward Diener wrote:
> On 4/15/2011 11:13 AM, Jeroen Habraken wrote:
>> Hi,
>>
>> Is there a specific yes_type and no_type inside boost that I should
>> be using when writing a SFINAE test? There seem to be quite a few
>> defined already and reinventing the wheel (albeit it being trivial)
>> again doesn't make sense.
>
> For the Boost developer there is:
>
> #include <boost/type_traits/detail/yes_no_type.hpp>
>
> you then have:
>
>>> boost::type_traits::yes_type
>>> boost::type_traits::no_type
>
> Of course the intention of 'detail' for a library is that the code
> should only be used by that library, but I think, in this case, it is
> allowable for other Boost library developers to use it also.
>
> But since this is a part of type traits detail it is not meant to be
> used outside of a Boost library ( ie. by end-users ).
>
> It would perhaps be better if ::boost::type_traits::yes_type and
>>> boost::type_traits::no_type were put into its own utility classes to
> make it more apparent that Boost library developers and end-users of
> Boost could use it.
>
> OTOH it might be presumptuous of me to suggest that it be used at all
> outside of type traits, but I have used it in my own TTI sandbox
> library anyway since type traits itself is used heavily there.

I think I'm using the one from MPL. If you use MPL for the compile time boolean operations with enable_if then you might as well use the ones in MPL. Actually, it turns out I'm inheriting from the ones in MPL, but it could have been a typedef.

  struct gtl_no : mpl::bool_<false> {};
  struct gtl_yes : mpl::bool_<true> {};

Regards,
Luke


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