1// Origin: PR c++/46162 2 3struct small_type { char dummy; }; 4struct large_type { char dummy[2]; }; 5 6template<class T> 7struct has_foo_member_variable 8{ 9 template<int T::*> struct tester; 10 template<class U> static small_type has_foo(tester<&U::foo> *); 11 template<class U> static large_type has_foo(...); 12 static const bool value = (sizeof(has_foo<T>(0)) == sizeof(small_type)); 13}; 14 15struct A 16{ 17 static int foo() 18 { 19 return 0; 20 } 21}; 22 23struct B 24{ 25 static int foo; 26}; 27 28void 29bar() 30{ 31 bool b = has_foo_member_variable<A>::value; 32} 33 34