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 11:15:29


On Tue, Apr 12, 2011 at 9:00 AM, Stewart, Robert <Robert.Stewart_at_[hidden]>wrote:

> I don't care for boost::enabler because "boost::" and "enable" are repeated
> (the first "enable" is in "enable_when") and a long line is made even
> longer. Note that the use of boost::enabler is optional: the type is void
> *&, so, for example, "= 0" works just as well and might be thought to negate
> enable_when.
>

You can't initialize a reference template parameter to 0 (I don't believe
you can for pointer parameters either for that matter).

If we go the route of making _when templates (which I'm not sure is a great
idea as it doubles the number of templates in Boost.Enable_If), the syntax
that I think would be best would be:

typename enable_when< is_arithmetic< T > >::type = {}

where ::type would refer to a detail enum, but unfortunately {} doesn't seem
to be a valid default for a template parameter. Does anyone know the
rationale for this offhand? I don't immediately see a problem with it. I
haven't looked at the standard but Comeau doesn't allow such defaults either
so I assume it's not just a broken implementation.

-- 
-Matt Calabrese

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