2 // (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
3 // Use, modification and distribution are subject to the Boost Software License,
4 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt).
7 // See http://www.boost.org/libs/type_traits for most recent version including documentation.
9 #ifndef BOOST_TT_IS_POD_HPP_INCLUDED
10 #define BOOST_TT_IS_POD_HPP_INCLUDED
12 #include <boost/type_traits/config.hpp>
13 #include <boost/type_traits/is_void.hpp>
14 #include <boost/type_traits/is_scalar.hpp>
15 #include <boost/type_traits/detail/ice_or.hpp>
16 #include <boost/type_traits/intrinsics.hpp>
20 // should be the last #include
21 #include <boost/type_traits/detail/bool_trait_def.hpp>
24 #define BOOST_INTERNAL_IS_POD(T) false
26 #define BOOST_INTERNAL_IS_POD(T) BOOST_IS_POD(T)
31 // forward declaration, needed by 'is_pod_array_helper' template below
32 template< typename T > struct is_POD;
36 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
38 template <typename T> struct is_pod_impl
40 BOOST_STATIC_CONSTANT(
42 (::boost::type_traits::ice_or<
43 ::boost::is_scalar<T>::value,
44 ::boost::is_void<T>::value,
45 BOOST_INTERNAL_IS_POD(T)
49 #if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
50 template <typename T, std::size_t sz>
51 struct is_pod_impl<T[sz]>
52 : public is_pod_impl<T>
59 template <bool is_array = false>
62 template <typename T> struct result_
64 BOOST_STATIC_CONSTANT(
66 (::boost::type_traits::ice_or<
67 ::boost::is_scalar<T>::value,
68 ::boost::is_void<T>::value,
69 BOOST_INTERNAL_IS_POD(T)
75 struct bool_to_yes_no_type
77 typedef ::boost::type_traits::no_type type;
81 struct bool_to_yes_no_type<true>
83 typedef ::boost::type_traits::yes_type type;
86 template <typename ArrayType>
87 struct is_pod_array_helper
89 enum { is_pod = ::boost::is_POD<ArrayType>::value }; // MSVC workaround
90 typedef typename bool_to_yes_no_type<is_pod>::type type;
91 type instance() const;
95 is_pod_array_helper<T> is_POD_array(T*);
98 struct is_pod_helper<true>
100 template <typename T> struct result_
103 BOOST_STATIC_CONSTANT(bool, value =
104 sizeof(is_POD_array(help()).instance()) == sizeof(::boost::type_traits::yes_type)
110 template <typename T> struct is_pod_impl
112 BOOST_STATIC_CONSTANT(
114 ::boost::detail::is_pod_helper<
115 ::boost::is_array<T>::value
116 >::template result_<T>::value
121 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
123 // the following help compilers without partial specialization support:
124 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void,true)
126 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
127 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void const,true)
128 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void volatile,true)
129 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void const volatile,true)
132 } // namespace detail
134 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pod,T,::boost::detail::is_pod_impl<T>::value)
135 // is_POD is the old depricated name for this trait, do not use this as it may
136 // be removed in future without warning!!
137 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_POD,T,::boost::is_pod<T>::value)
141 #include <boost/type_traits/detail/bool_trait_undef.hpp>
143 #undef BOOST_INTERNAL_IS_POD
145 #endif // BOOST_TT_IS_POD_HPP_INCLUDED