3 // Test of the use of member functions with SFINAE
5 struct no_type { char data[2]; };
7 template<typename T> T create_a();
9 template<bool, typename T = void> struct enable_if { typedef T type; };
10 template<typename T> struct enable_if<false, T> { };
13 typename enable_if<(sizeof(create_a<T>().foo(), 1) > 0),
15 check_has_member_foo(const volatile T&);
17 no_type check_has_member_foo(...);
22 static const bool value =
23 (sizeof(check_has_member_foo(create_a<T const&>())) == sizeof(yes_type));
42 int a1[has_foo<X>::value? -1 : 1];
43 int a2[has_foo<Y>::value? 1 : -1];
44 int a3[has_foo<Z>::value? -1 : 1];
45 int a4[has_foo<int>::value? -1 : 1];
46 int a5[has_foo<A>::value? -1 : 1];
47 int a6[has_foo<B>::value? 1 : -1];