Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-03-13 17:57:31


I am solving this problem, and considerably simplifying the type_traits
workaround implementations to boot. If you want a preview, have a look
at composite_traits.hpp from the CVS.

template <class T> T(*
    helper1(type<T>)
)(type<T>);

no_type helper2(T&(*)(type<T>));
yes_type helper2(...);

template <class T>
struct is_array
{
    BOOST_STATIC_CONSTANT(bool, value = helper2(helper1(type<T>())));
};

How this works, as far as I can tell:

* helper1 returns a pointer-to-function accepting type<T> and returning
T.
* when T is an array type, that's illegal, so MSVC turns it into a
function returning T*
* only helper2(...) will match that transformed function pointer.

-Dave


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