Subject: Re: [boost] New, powerful way to use enable_if in C++0x
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2011-04-12 08:27:02
2011/4/12 Stewart, Robert <Robert.Stewart_at_[hidden]>
> 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
> 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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk