Boost logo

Boost :

Subject: Re: [boost] New, powerful way to use enable_if in C++0x
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-04-13 13:35:45


On Wed, Apr 13, 2011 at 10:17 AM, Thorsten Ottosen <
thorsten.ottosen_at_[hidden]> wrote:

> Den 13-04-2011 10:14, Daniel Frey skrev:
>
>> On 11.04.2011, at 20:15, Matt Calabrese wrote:
>>
>
> That's really nice, but I think the syntax might be improved. How
>> about adding a ::value to enable_if (and the other templates) to
>> allow your example to look like this:
>>
>> template< class... T, bool = boost::enable_if_c< sizeof...( T ) ==
>> 10>::value> test( T&&... );
>>
>> template< class T, bool = boost::enable_if< boost::is_arithmetic<
>> T> >::value> operator T() const;
>>
>> etc.? Get rid of typename, *&, boost::enabler and if you like, you
>> can write 'bool Enabled = ...' instead of 'bool = ...' to be more
>> verbose in your code.
>>
>
> Hm. Why not
>
> template< class T, BOOST_ENABLE_WHEN( boost::is_xxx<T> ) >
>
> ?
>

That would likely have issues with commas in the conditional, which I don't
think "double parens" could fix. That is, it's a problem unless all C++0x
compilers which support this use of SFINAE also support variadic
templates...

- Jeff


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