|
Boost : |
Subject: Re: [boost] New, powerful way to use enable_if in C++0x
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2011-04-13 14:02:42
On Wed, Apr 13, 2011 at 1:35 PM, Jeffrey Lee Hellrung, Jr. <
jeffrey.hellrung_at_[hidden]> wrote:
> 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...
I assume you mean variadic macros not variadic templates? Double parentheses
would work fine when the compiler doesn't support variadic macros. Just
define the macro as such, or similar:
#define BOOST_ENABLE_IF( condition )\
typename ::boost::enable_if\
< typename ::boost::function_traits< void condition >::arg1_type\
, int >::type = 0
In fact it's possible to supply a simple variadic version when available and
a regular macro similar to the one above when not, having the same macro
name in either case without issue. You'd do this by making the variadic
version check if the argument is parenthesized (which is possible with the
preprocessor) and simply strip the parentheses if they are there. This
allows backward compatibility by allowing people to specify either
parenthesized or unparenthesized arguments.
Anyway, all of this parentheses hubbub is probably unecessary since as far
as I know all compilers that have any experimental C++0x support already
also support variadic macros (probably in part because of C99).
-- -Matt Calabrese
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk