Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-03-13 11:03:28


From: "David Abrahams" <david.abrahams_at_[hidden]>
> It seems that the known technologies for writing type traits for
> compilers without partial specialization nearly always force us to
> choose between supporting array types and supporting abstract classes.
> Let's just look at is_pointer, for an example:
>
> ----------
> struct pointer_helper
> {
> pointer_helper(const volatile void*);
> };
> yes_type BOOST_TT_DECL is_pointer_helper(pointer_helper);
> no_type BOOST_TT_DECL is_pointer_helper(...);
>
>
> template <typename T>
> struct is_pointer
> {
> private:
> static T t;

The canonical workaround is to wrap in boost::type<> (code off the top of my
head):

template<class T> yes_type is_pointer_helper(type<T*>);
no_type is_pointer_helper(...);

is_pointer<T>::value = sizeof(yes_type) ==
sizeof(is_pointer_helper(type<T>()));

Does it work here?


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