forked from boostorg/type_traits
Added fixes for gcc, to fix remaining regressions with is_class/is_convertible and is_enum
[SVN r21513]
This commit is contained in:
@ -24,7 +24,7 @@
|
||||
# define BOOST_TT_DECL /**/
|
||||
#endif
|
||||
|
||||
# if (defined(__MWERKS__) && __MWERKS__ >= 0x3000) || (defined(BOOST_MSVC) && (BOOST_MSVC > 1301)) || defined(__EDG_VERSION__) || defined(BOOST_NO_COMPILER_CONFIG)
|
||||
# if (defined(__MWERKS__) && __MWERKS__ >= 0x3000) || (defined(BOOST_MSVC) && (BOOST_MSVC > 1301)) || defined(__EDG_VERSION__) || (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(BOOST_NO_COMPILER_CONFIG)
|
||||
# define BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
|
||||
#endif
|
||||
|
||||
|
@ -48,6 +48,24 @@ namespace detail {
|
||||
// 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
|
||||
#ifdef __GNUC__
|
||||
|
||||
template <class U> static ::boost::type_traits::yes_type is_class_tester(void(U::*)(void));
|
||||
template <class U> static ::boost::type_traits::no_type is_class_tester(...);
|
||||
|
||||
template <typename T>
|
||||
struct is_class_impl
|
||||
{
|
||||
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
(::boost::type_traits::ice_and<
|
||||
sizeof(is_class_tester<T>(0)) == sizeof(::boost::type_traits::yes_type),
|
||||
::boost::type_traits::ice_not< ::boost::is_union<T>::value >::value
|
||||
>::value)
|
||||
);
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template <typename T>
|
||||
struct is_class_impl
|
||||
@ -82,6 +100,7 @@ struct is_class_impl<T const volatile>
|
||||
{
|
||||
};
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
|
@ -107,7 +107,7 @@ struct is_convertible_impl
|
||||
struct any_conversion
|
||||
{
|
||||
template <typename T> any_conversion(const volatile T&);
|
||||
//template <typename T> any_conversion(T&);
|
||||
template <typename T> any_conversion(T&);
|
||||
};
|
||||
|
||||
template <typename T> struct checker
|
||||
@ -124,8 +124,7 @@ struct is_convertible_basic_impl
|
||||
== sizeof(::boost::type_traits::yes_type);
|
||||
};
|
||||
|
||||
#elif (defined(BOOST_MSVC) && (BOOST_MSVC > 1310)) \
|
||||
|| (defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 245) && !defined(__ICL)) \
|
||||
#elif (defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 245) && !defined(__ICL)) \
|
||||
|| defined(__IBMCPP__)
|
||||
//
|
||||
// This is *almost* an ideal world implementation as it doesn't rely
|
||||
@ -133,6 +132,10 @@ struct is_convertible_basic_impl
|
||||
// Unfortunately it doesn't quite pass all the tests for most compilers (sigh...)
|
||||
// Enable this for your compiler if is_convertible_test.cpp will compile it...
|
||||
//
|
||||
// Note we do not enable this for VC7.1, because even though it passes all the
|
||||
// type_traits tests it is known to cause problems when instantiation occurs
|
||||
// deep within the instantiation tree :-(
|
||||
//
|
||||
struct any_conversion
|
||||
{
|
||||
template <typename T> any_conversion(const volatile T&);
|
||||
|
@ -19,6 +19,11 @@
|
||||
#include <boost/type_traits/is_function.hpp>
|
||||
#endif
|
||||
#include "boost/type_traits/config.hpp"
|
||||
#if defined(BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION)
|
||||
# include <boost/type_traits/is_class.hpp>
|
||||
# include <boost/type_traits/is_union.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
// should be the last #include
|
||||
#include "boost/type_traits/detail/bool_trait_def.hpp"
|
||||
@ -29,6 +34,20 @@ namespace boost {
|
||||
|
||||
namespace detail {
|
||||
|
||||
#if defined(BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION)
|
||||
|
||||
template <typename T>
|
||||
struct is_class_or_union
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value =
|
||||
(::boost::type_traits::ice_or<
|
||||
::boost::is_class<T>::value
|
||||
, ::boost::is_union<T>::value
|
||||
>::value));
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template <typename T>
|
||||
struct is_class_or_union
|
||||
{
|
||||
@ -50,6 +69,7 @@ struct is_class_or_union
|
||||
# endif
|
||||
# endif
|
||||
};
|
||||
#endif
|
||||
|
||||
struct int_convertible
|
||||
{
|
||||
@ -81,13 +101,25 @@ template <typename T> struct is_enum_impl
|
||||
typedef ::boost::add_reference<T> ar_t;
|
||||
typedef typename ar_t::type r_type;
|
||||
|
||||
#if defined __GNUC__
|
||||
#if defined(__GNUC__)
|
||||
|
||||
#ifdef BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
|
||||
BOOST_STATIC_CONSTANT(bool, selector =
|
||||
(::boost::type_traits::ice_or<
|
||||
::boost::is_arithmetic<T>::value
|
||||
, ::boost::is_reference<T>::value
|
||||
, ::boost::is_function<T>::value
|
||||
, is_class_or_union<T>::value
|
||||
>::value));
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, selector =
|
||||
(::boost::type_traits::ice_or<
|
||||
::boost::is_arithmetic<T>::value
|
||||
, ::boost::is_reference<T>::value
|
||||
, ::boost::is_function<T>::value
|
||||
>::value));
|
||||
#endif // BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION
|
||||
|
||||
#else
|
||||
BOOST_STATIC_CONSTANT(bool, selector =
|
||||
(::boost::type_traits::ice_or<
|
||||
|
@ -21,6 +21,7 @@
|
||||
# include <boost/type_traits/has_trivial_destructor.hpp>
|
||||
# include <boost/type_traits/is_compound.hpp>
|
||||
# include <boost/type_traits/is_base_and_derived.hpp>
|
||||
# include <boost/type_traits/is_convertible.hpp>
|
||||
#endif
|
||||
|
||||
TT_TEST_BEGIN(tricky_function_type_test)
|
||||
@ -39,6 +40,7 @@ BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_copy<foo0_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_assign<foo0_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::has_trivial_destructor<foo0_t>::value, false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived<foo0_t, foo0_t>::value), false);
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_convertible<foo0_t, int>::value), false);
|
||||
|
||||
|
||||
BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_class<foo1_t>::value, false);
|
||||
|
Reference in New Issue
Block a user