diff --git a/include/boost/type_traits/object_traits.hpp b/include/boost/type_traits/object_traits.hpp index 867b3a5..22bcfcc 100644 --- a/include/boost/type_traits/object_traits.hpp +++ b/include/boost/type_traits/object_traits.hpp @@ -88,6 +88,23 @@ template struct is_class { #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +# if (defined(__MWERKS__) && __MWERKS__ >= 0x3000) || BOOST_MSVC >= 1300 || defined(BOOST_NO_COMPILER_CONFIG) + // This is actually the conforming implementation which works with + // abstract classes. However, enough compilers have trouble with + // it that most will use the following one. + +// is_class<> metafunction due to Paul Mensonides +// (leavings@attbi.com). For more details: +// http://groups.google.com/groups?hl=en&selm=000001c1cc83%24e154d5e0%247772e50c%40c161550a&rnum=1 + private: + template static ::boost::type_traits::yes_type is_class_helper(void(U::*)(void)); + template static ::boost::type_traits::no_type is_class_helper(...); + public: + BOOST_STATIC_CONSTANT( + bool, value = sizeof( + is_class_helper(0) + ) == sizeof(::boost::type_traits::yes_type)); +# else BOOST_STATIC_CONSTANT(bool, value = (::boost::type_traits::ice_and< ::boost::type_traits::ice_not< ::boost::is_union::value >::value, @@ -97,6 +114,7 @@ struct is_class ::boost::type_traits::ice_not< ::boost::is_void::value >::value, ::boost::type_traits::ice_not< ::boost::is_function::value >::value >::value)); +# endif #else BOOST_STATIC_CONSTANT(bool, value = (::boost::type_traits::ice_and< @@ -348,11 +366,11 @@ struct empty_helper_t1 : public T }; struct empty_helper_t2 { int i[256]; }; -template +template struct empty_helper{ BOOST_STATIC_CONSTANT(bool, value = false); }; template -struct empty_helper +struct empty_helper { BOOST_STATIC_CONSTANT(bool, value = (sizeof(empty_helper_t1) == sizeof(empty_helper_t2))); @@ -369,8 +387,7 @@ public: BOOST_STATIC_CONSTANT(bool, value = (::boost::type_traits::ice_or< ::boost::detail::empty_helper::value , - ::boost::is_convertible< r_type,int>::value + ::boost::is_class::value >::value, BOOST_IS_EMPTY(cvt) >::value)); diff --git a/tests/composite_traits_test.cpp b/tests/composite_traits_test.cpp index f53c13e..034278e 100644 --- a/tests/composite_traits_test.cpp +++ b/tests/composite_traits_test.cpp @@ -146,7 +146,7 @@ unsigned int expected_failures = 1; // can't handle cv-qualified references # endif #elif defined(BOOST_MSVC) unsigned int expected_failures = 0; -#elif defined(__MWERKS__) && __MWERKS__ <= 0x2407 || defined(__HP_aCC) +#elif defined(__MWERKS__) && __MWERKS__ < 0x3000 || defined(__HP_aCC) unsigned int expected_failures = 1; // is_enum doesn't work #else unsigned int expected_failures = 0; diff --git a/tests/object_type_traits_test.cpp b/tests/object_type_traits_test.cpp index e12b279..cc7c0c0 100644 --- a/tests/object_type_traits_test.cpp +++ b/tests/object_type_traits_test.cpp @@ -243,7 +243,7 @@ int cpp_main(int argc, char* argv[]) soft_value_test(false, boost::is_empty::value) soft_value_test(false, boost::is_empty::value) soft_value_test(false, boost::is_empty::value) -#if defined(__MWERKS__) || defined(__HP_aCC) +#if defined(__MWERKS__) && __MWERKS__ < 0x3000 || defined(__HP_aCC) // apparent compiler bug causes this to fail to compile: value_fail(false, boost::is_empty::value) #else @@ -258,7 +258,7 @@ int cpp_main(int argc, char* argv[]) // because we can't tell the difference between // unions and classes: value_fail(true, boost::is_empty::value) -#if defined(__MWERKS__) || defined(__HP_aCC) +#if defined(__MWERKS__) && __MWERKS__ < 0x3000 || defined(__HP_aCC) // apparent compiler bug causes this to fail to compile: value_fail(false, boost::is_empty::value) #else @@ -303,7 +303,7 @@ unsigned int expected_failures = 25; #else unsigned int expected_failures = 0; #endif -#elif defined(__MWERKS__) +#elif defined(__MWERKS__) && __MWERKS__ < 0x3000 unsigned int expected_failures = 10; #elif defined(BOOST_MSVC) unsigned int expected_failures = 0;