|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2002-12-06 07:58:48
Aleksey Gurtovoy <agurtovoy_at_[hidden]> writes:
> David B. Held wrote:
>> > In "C++ Templates: The Complete Guide" (Recommended), they give
>> > this example on pages 106-107:
>> >
>> > typedef char RT1;
>> > typedef struct {char a[2];} RT2;
>> > template<typename T> RT1 test(typename T::X const*);
>> > template<typename T> RT2 test(...);
>> >
>> > #define type_has_member_type_X(T) \
>> > (sizeof(test<T>(0) == 1)
>>
>> This is cool. What compilers are known to support it?
>
> MPL's implementation ("boost/mpl/aux_/has_xxx.hpp") is known to work on
> Comeau, Intel (all versions), MSVC (all versions), Metroweks 8.3/8.2 and GCC
> 3.2. There is no known way to make it work on Borland. You can test it
> against any other compiler by trying out
> "boost/libs/mpl/test/aux_/has_xxx.cpp" test case.
It also works with GCC 2.95.2 with some restrictions. I don't remember
what they are offhand. Something like that the type must be a class?
... that doesn't sound quite right because we could work around it
with an is_class pre-test.
-- David Abrahams dave_at_[hidden] * http://www.boost-consulting.com Boost support, enhancements, training, and commercial distribution
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk