Boost logo

Boost :

Subject: Re: [boost] [type_traits] is_constructible, ... when decltype is supported?
From: John Maddock (boost.regex_at_[hidden])
Date: 2011-06-07 06:40:05


> 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(...);
>
> Unfortunately, Boost.TypeOf can not be used for the failing checks, as
> compilation fails.
>
> I have committed them in the sandbox under
> conversion/boost/conversion/type_traits.

Cool!

I think it would be good to have these in type_traits, currently though it
seems that only GCC will compile the code - VC10 fails irrespective of
whether BOOST_NO_DECLTYPE is set or not :-( I don't suppose there's any
chance of a fix/workaround for this? I couldn't see one from a quick hack
around, but I thought I'd ask anyway ;-)

Cheers, John.


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