1// (C) Copyright Mathias Gaunard 2009. 2// Use, modification and distribution are subject to the 3// Boost Software License, Version 1.0. (See accompanying file 4// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6// See http://www.boost.org/libs/config for the most recent version. 7 8// MACRO: BOOST_NO_SFINAE_EXPR 9// TITLE: SFINAE for expressions 10// DESCRIPTION: SFINAE for expressions not supported. 11 12namespace boost_no_sfinae_expr 13{ 14 15template<typename T> 16struct has_foo 17{ 18 typedef char NotFound; 19 struct Found { char x[2]; }; 20 21 template<int> struct dummy {}; 22 23 template<class X> static Found test(dummy< sizeof((*(X*)0).foo(), 0) >*); 24 template<class X> static NotFound test( ... ); 25 26 static const bool value = (sizeof(Found) == sizeof(test<T>(0))); 27}; 28 29struct test1 {}; 30struct test2 { void foo(); }; 31 32int test() 33{ 34 return has_foo<test1>::value || !has_foo<test2>::value; 35} 36 37} // namespace boost_no_sfinae_expr 38