Boost logo

Boost :

Subject: Re: [boost] New, powerful way to use enable_if in C++0x
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2011-04-12 16:56:38


On Tue, Apr 12, 2011 at 4:34 PM, Jeremy Maitin-Shepard
<jeremy_at_[hidden]>wrote:

> It seems that template aliases would further improve the syntax, but they
> are not yet supported by any compilers as far as I know.
>

Would SFINAE actually apply there or is that a level of indirection, causing
a hard error? To be clear, I'm imagining something like this:

template< bool V > struct enable_when_c_impl {};

template<>
struct enable_when_c_impl< true >
{
  typedef int type;
};

template< bool V >
using enable_when_c = typename enable_when_c_impl< V >::type;

// SFINAE or error here when the condition is false?
template< class T, enable_when_c< sizeof( T ) == 4 > = 0 >
void foo( T );

-- 
-Matt Calabrese

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