
2011/4/12 Stewart, Robert <Robert.Stewart@sig.com>
Matt Calabrese wrote:
I realized today that enable_if can be used in a new way in C++0x.
This is very slick, as so many have noted already. However, I wonder if you couldn't repackage your idea in, say, enable_when and disable_when (plus variants) so that the usage is slightly simpler:
class test { template < class... T , typename boost::enable_when_c<sizeof...(T) == 10>::type = true
test(T &&...); };
IOW, enable_when_c would expose a nested type, type, of type bool that makes forming the default easy[*]. You could use a pointer or integer type and default to 0, for example, but expressing the default as "= true" just looks good and is easy to remember.
Enable_when looks good to me, except for one detail: "enable_when< [...]
::type = true" may confuse someone, that "enable_when< [...] >::type = false" is a synonym for "disable_when< [...] >::type = true", so I'm be against the part "= true". I'd most like it to be "= 0", but "= boost::enabler" looks ok to me too.
Regards, Kris