Boost logo

Boost :

Subject: Re: [boost] [type_traits] is_constructible, ... when decltype is supported?
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-06-07 11:02:08


On 05/06/2011 22:32, Vicente Botet wrote:

> We can use it as the return type of the test function. FOr example to test
> if T can be constructed with two parameters A1, A2
>
> decltype((T(declval<A1>(),declval<A2>()), true_type())) test(int);
> false_type test(...);

You realize you can do the same thing with sizeof in C++03, when
BOOST_NO_SFINAE_EXPR is not defined?

Also you shouldn't use decltype directly in the return type if you want
portability, it caused mangling problems with some GCC versions.

Attached is a C++03-compatible version.




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