diff --git a/include/boost/type_traits/config.hpp b/include/boost/type_traits/config.hpp index a2bf635..b54af77 100644 --- a/include/boost/type_traits/config.hpp +++ b/include/boost/type_traits/config.hpp @@ -25,69 +25,6 @@ # define BOOST_TT_DECL /**/ #endif -// -// Helper macros for builtin compiler support. -// If your compiler has builtin support for any of the following -// traits concepts, then redefine the appropriate macros to pick -// up on the compiler support: -// -// (these should largely ignore cv-qualifiers) -// BOOST_IS_CLASS(T) should evaluate to true if T is a class or struct type -// BOOST_IS_ENUM(T) should evaluate to true if T is an enumerator type -// BOOST_IS_UNION(T) should evaluate to true if T is a union type -// BOOST_IS_POD(T) should evaluate to true if T is a POD type -// BOOST_IS_EMPTY(T) should evaluate to true if T is an empty struct or union -// BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) should evaluate to true if "T x;" has no effect -// BOOST_HAS_TRIVIAL_COPY(T) should evaluate to true if T(t) <==> memcpy -// BOOST_HAS_TRIVIAL_ASSIGN(T) should evaluate to true if t = u <==> memcpy -// BOOST_HAS_TRIVIAL_DESTRUCTOR(T) should evaluate to true if ~T() has no effect - -#ifdef BOOST_HAS_SGI_TYPE_TRAITS -# include "boost/type_traits/is_same.hpp" -# include -# define BOOST_IS_POD(T) ::boost::is_same< typename ::__type_traits::is_POD_type, ::__true_type>::value -# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) ::boost::is_same< typename ::__type_traits::has_trivial_default_constructor, ::__true_type>::value -# define BOOST_HAS_TRIVIAL_COPY(T) ::boost::is_same< typename ::__type_traits::has_trivial_copy_constructor, ::__true_type>::value -# define BOOST_HAS_TRIVIAL_ASSIGN(T) ::boost::is_same< typename ::__type_traits::has_trivial_assignment_operator, ::__true_type>::value -# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) ::boost::is_same< typename ::__type_traits::has_trivial_destructor, ::__true_type>::value -#endif - -#ifndef BOOST_IS_CLASS -# define BOOST_IS_CLASS(T) false -#endif - -#ifndef BOOST_IS_ENUM -# define BOOST_IS_ENUM(T) false -#endif - -#ifndef BOOST_IS_UNION -# define BOOST_IS_UNION(T) false -#endif - -#ifndef BOOST_IS_POD -# define BOOST_IS_POD(T) false -#endif - -#ifndef BOOST_IS_EMPTY -# define BOOST_IS_EMPTY(T) false -#endif - -#ifndef BOOST_HAS_TRIVIAL_CONSTRUCTOR -# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) false -#endif - -#ifndef BOOST_HAS_TRIVIAL_COPY -# define BOOST_HAS_TRIVIAL_COPY(T) false -#endif - -#ifndef BOOST_HAS_TRIVIAL_ASSIGN -# define BOOST_HAS_TRIVIAL_ASSIGN(T) false -#endif - -#ifndef BOOST_HAS_TRIVIAL_DESTRUCTOR -# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) false -#endif - # if (defined(__MWERKS__) && __MWERKS__ >= 0x3000) || BOOST_MSVC > 1301 || defined(BOOST_NO_COMPILER_CONFIG) # define BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION #endif diff --git a/include/boost/type_traits/has_trivial_assign.hpp b/include/boost/type_traits/has_trivial_assign.hpp index a6afb52..71c4ae6 100644 --- a/include/boost/type_traits/has_trivial_assign.hpp +++ b/include/boost/type_traits/has_trivial_assign.hpp @@ -10,13 +10,14 @@ #ifndef BOOST_TT_HAS_TRIVIAL_ASSIGN_HPP_INCLUDED #define BOOST_TT_HAS_TRIVIAL_ASSIGN_HPP_INCLUDED +#include "boost/type_traits/config.hpp" +#include "boost/type_traits/intrinsics.hpp" #include "boost/type_traits/is_pod.hpp" #include "boost/type_traits/is_const.hpp" #include "boost/type_traits/is_volatile.hpp" #include "boost/type_traits/detail/ice_and.hpp" #include "boost/type_traits/detail/ice_or.hpp" #include "boost/type_traits/detail/ice_not.hpp" -#include "boost/type_traits/config.hpp" // should be the last #include #include "boost/type_traits/detail/bool_trait_def.hpp" diff --git a/include/boost/type_traits/has_trivial_constructor.hpp b/include/boost/type_traits/has_trivial_constructor.hpp index 4dabab4..3a74f17 100644 --- a/include/boost/type_traits/has_trivial_constructor.hpp +++ b/include/boost/type_traits/has_trivial_constructor.hpp @@ -10,9 +10,10 @@ #ifndef BOOST_TT_HAS_TRIVIAL_CONSTRUCTOR_HPP_INCLUDED #define BOOST_TT_HAS_TRIVIAL_CONSTRUCTOR_HPP_INCLUDED +#include "boost/type_traits/config.hpp" +#include "boost/type_traits/intrinsics.hpp" #include "boost/type_traits/is_pod.hpp" #include "boost/type_traits/detail/ice_or.hpp" -#include "boost/type_traits/config.hpp" // should be the last #include #include "boost/type_traits/detail/bool_trait_def.hpp" diff --git a/include/boost/type_traits/has_trivial_copy.hpp b/include/boost/type_traits/has_trivial_copy.hpp index 9bc8421..ffd475c 100644 --- a/include/boost/type_traits/has_trivial_copy.hpp +++ b/include/boost/type_traits/has_trivial_copy.hpp @@ -10,12 +10,13 @@ #ifndef BOOST_TT_HAS_TRIVIAL_COPY_HPP_INCLUDED #define BOOST_TT_HAS_TRIVIAL_COPY_HPP_INCLUDED +#include "boost/type_traits/config.hpp" +#include "boost/type_traits/intrinsics.hpp" #include "boost/type_traits/is_volatile.hpp" #include "boost/type_traits/is_pod.hpp" #include "boost/type_traits/detail/ice_and.hpp" #include "boost/type_traits/detail/ice_or.hpp" #include "boost/type_traits/detail/ice_not.hpp" -#include "boost/type_traits/config.hpp" // should be the last #include #include "boost/type_traits/detail/bool_trait_def.hpp" diff --git a/include/boost/type_traits/has_trivial_destructor.hpp b/include/boost/type_traits/has_trivial_destructor.hpp index b0f9d16..97aab19 100644 --- a/include/boost/type_traits/has_trivial_destructor.hpp +++ b/include/boost/type_traits/has_trivial_destructor.hpp @@ -10,9 +10,10 @@ #ifndef BOOST_TT_HAS_TRIVIAL_DESTRUCTOR_HPP_INCLUDED #define BOOST_TT_HAS_TRIVIAL_DESTRUCTOR_HPP_INCLUDED +#include "boost/type_traits/config.hpp" +#include "boost/type_traits/intrinsics.hpp" #include "boost/type_traits/is_pod.hpp" #include "boost/type_traits/detail/ice_or.hpp" -#include "boost/type_traits/config.hpp" // should be the last #include #include "boost/type_traits/detail/bool_trait_def.hpp" diff --git a/include/boost/type_traits/intrinsics.hpp b/include/boost/type_traits/intrinsics.hpp new file mode 100644 index 0000000..58a31c2 --- /dev/null +++ b/include/boost/type_traits/intrinsics.hpp @@ -0,0 +1,92 @@ + +// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000. +// Permission to copy, use, modify, sell and distribute this software is +// granted provided this copyright notice appears in all copies. This software +// is provided "as is" without express or implied warranty, and with no claim +// as to its suitability for any purpose. +// +// See http://www.boost.org for most recent version including documentation. + +#ifndef BOOST_TT_INTRINSICS_HPP_INCLUDED +#define BOOST_TT_INTRINSICS_HPP_INCLUDED + +#ifndef BOOST_TT_CONFIG_HPP_INCLUDED +#include "boost/type_traits/config.hpp" +#endif + +// +// Helper macros for builtin compiler support. +// If your compiler has builtin support for any of the following +// traits concepts, then redefine the appropriate macros to pick +// up on the compiler support: +// +// (these should largely ignore cv-qualifiers) +// BOOST_IS_CLASS(T) should evaluate to true if T is a class or struct type +// BOOST_IS_ENUM(T) should evaluate to true if T is an enumerator type +// BOOST_IS_UNION(T) should evaluate to true if T is a union type +// BOOST_IS_POD(T) should evaluate to true if T is a POD type +// BOOST_IS_EMPTY(T) should evaluate to true if T is an empty struct or union +// BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) should evaluate to true if "T x;" has no effect +// BOOST_HAS_TRIVIAL_COPY(T) should evaluate to true if T(t) <==> memcpy +// BOOST_HAS_TRIVIAL_ASSIGN(T) should evaluate to true if t = u <==> memcpy +// BOOST_HAS_TRIVIAL_DESTRUCTOR(T) should evaluate to true if ~T() has no effect + +#ifdef BOOST_HAS_SGI_TYPE_TRAITS +# include "boost/type_traits/is_same.hpp" +# include +# define BOOST_IS_POD(T) ::boost::is_same< typename ::__type_traits::is_POD_type, ::__true_type>::value +# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) ::boost::is_same< typename ::__type_traits::has_trivial_default_constructor, ::__true_type>::value +# define BOOST_HAS_TRIVIAL_COPY(T) ::boost::is_same< typename ::__type_traits::has_trivial_copy_constructor, ::__true_type>::value +# define BOOST_HAS_TRIVIAL_ASSIGN(T) ::boost::is_same< typename ::__type_traits::has_trivial_assignment_operator, ::__true_type>::value +# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) ::boost::is_same< typename ::__type_traits::has_trivial_destructor, ::__true_type>::value +#endif + +#if defined(__MSL_CPP__) && (__MSL_CPP__ >= 0x8000) +# include +# define BOOST_IS_UNION(T) BOOST_STD_EXTENSION_NAMESPACE::is_union::value +# define BOOST_IS_POD(T) BOOST_STD_EXTENSION_NAMESPACE::is_POD::value +# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_constructor::value +# define BOOST_HAS_TRIVIAL_COPY(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_copy::value +# define BOOST_HAS_TRIVIAL_ASSIGN(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_assign::value +# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_destructor::value +#endif + +#ifndef BOOST_IS_CLASS +# define BOOST_IS_CLASS(T) false +#endif + +#ifndef BOOST_IS_ENUM +# define BOOST_IS_ENUM(T) false +#endif + +#ifndef BOOST_IS_UNION +# define BOOST_IS_UNION(T) false +#endif + +#ifndef BOOST_IS_POD +# define BOOST_IS_POD(T) false +#endif + +#ifndef BOOST_IS_EMPTY +# define BOOST_IS_EMPTY(T) false +#endif + +#ifndef BOOST_HAS_TRIVIAL_CONSTRUCTOR +# define BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) false +#endif + +#ifndef BOOST_HAS_TRIVIAL_COPY +# define BOOST_HAS_TRIVIAL_COPY(T) false +#endif + +#ifndef BOOST_HAS_TRIVIAL_ASSIGN +# define BOOST_HAS_TRIVIAL_ASSIGN(T) false +#endif + +#ifndef BOOST_HAS_TRIVIAL_DESTRUCTOR +# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) false +#endif + +#endif // BOOST_TT_INTRINSICS_HPP_INCLUDED + + diff --git a/include/boost/type_traits/is_class.hpp b/include/boost/type_traits/is_class.hpp index c652491..15d8df9 100644 --- a/include/boost/type_traits/is_class.hpp +++ b/include/boost/type_traits/is_class.hpp @@ -11,18 +11,18 @@ #define BOOST_TT_IS_CLASS_HPP_INCLUDED #include "boost/type_traits/config.hpp" +# include "boost/type_traits/is_union.hpp" +# include "boost/type_traits/detail/ice_and.hpp" +# include "boost/type_traits/detail/ice_not.hpp" #ifdef BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION # include "boost/type_traits/detail/yes_no_type.hpp" #else -# include "boost/type_traits/is_union.hpp" # include "boost/type_traits/is_scalar.hpp" # include "boost/type_traits/is_array.hpp" # include "boost/type_traits/is_reference.hpp" # include "boost/type_traits/is_void.hpp" # include "boost/type_traits/is_function.hpp" -# include "boost/type_traits/detail/ice_and.hpp" -# include "boost/type_traits/detail/ice_not.hpp" #endif // should be the last #include @@ -52,7 +52,10 @@ struct is_class_impl template static ::boost::type_traits::no_type is_class_tester(...); BOOST_STATIC_CONSTANT(bool, value = - sizeof(is_class_tester(0)) == sizeof(::boost::type_traits::yes_type) + (::boost::type_traits::ice_and< + sizeof(is_class_tester(0)) == sizeof(::boost::type_traits::yes_type), + ::boost::type_traits::ice_not< ::boost::is_union::value >::value + >::value) ); }; diff --git a/include/boost/type_traits/is_pod.hpp b/include/boost/type_traits/is_pod.hpp index 700d1e4..606a2e8 100644 --- a/include/boost/type_traits/is_pod.hpp +++ b/include/boost/type_traits/is_pod.hpp @@ -10,10 +10,11 @@ #ifndef BOOST_TT_IS_POD_HPP_INCLUDED #define BOOST_TT_IS_POD_HPP_INCLUDED +#include "boost/type_traits/config.hpp" #include "boost/type_traits/is_void.hpp" #include "boost/type_traits/is_scalar.hpp" #include "boost/type_traits/detail/ice_or.hpp" -#include "boost/type_traits/config.hpp" +#include "boost/type_traits/intrinsics.hpp" #include diff --git a/include/boost/type_traits/is_union.hpp b/include/boost/type_traits/is_union.hpp index 507c000..5a2c3f9 100644 --- a/include/boost/type_traits/is_union.hpp +++ b/include/boost/type_traits/is_union.hpp @@ -13,6 +13,7 @@ #include "boost/type_traits/remove_cv.hpp" #include "boost/type_traits/config.hpp" +#include "boost/type_traits/intrinsics.hpp" // should be the last #include #include "boost/type_traits/detail/bool_trait_def.hpp"