1// (C) Copyright John Maddock and Dave Abrahams 2002. 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 most recent version. 7 8// MACRO: BOOST_NO_IS_ABSTRACT 9// TITLE: is_abstract implementation technique 10// DESCRIPTION: Some compilers can't handle the code used for is_abstract even if they support SFINAE. 11 12 13namespace boost_no_is_abstract{ 14 15#if defined(BOOST_CODEGEARC) 16template<class T> 17struct is_abstract_test 18{ 19 enum{ value = __is_abstract(T) }; 20}; 21#else 22template<class T> 23struct is_abstract_test 24{ 25 // Deduction fails if T is void, function type, 26 // reference type (14.8.2/2)or an abstract class type 27 // according to review status issue #337 28 // 29 template<class U> 30 static double check_sig(U (*)[1]); 31 template<class U> 32 static char check_sig(...); 33 34#ifdef __GNUC__ 35 enum{ s1 = sizeof(is_abstract_test<T>::template check_sig<T>(0)) }; 36#else 37 enum{ s1 = sizeof(check_sig<T>(0)) }; 38#endif 39 40 enum{ value = (s1 == sizeof(char)) }; 41}; 42#endif 43 44struct non_abstract{}; 45struct abstract{ virtual void foo() = 0; }; 46 47int test() 48{ 49 return static_cast<bool>(is_abstract_test<non_abstract>::value) == static_cast<bool>(is_abstract_test<abstract>::value); 50} 51 52} 53 54