Boost logo

Boost :

From: Jon Kalb (jonkalb_at_[hidden])
Date: 2002-12-05 14:27:42

> -----Original Message-----
> From: David B. Held [mailto:dheld_at_[hidden]]
> Sent: Thursday, December 05, 2002 10:56 AM
> To: boost_at_[hidden]
> Subject: [boost] Re: [MPL] Making Generators
> "David Abrahams" <dave_at_[hidden]> wrote in message
> > [...]
> > I don't know... well, it could detect whether there was a ::type
> > member, [...]
> Really??? Is it possible to detect the presence of a typedef
> without generating an error? How do you do this? I think
> this is a very useful feature!
> Dave

Vandevoorde and Josuttis call it SFINAE, "substitution failute is not an

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)

Boost list run by bdawes at, gregod at, cpdaniel at, john at