]> git.donarmstrong.com Git - rsem.git/blob - boost/type_traits/is_pod.hpp
Updated boost to v1.55.0
[rsem.git] / boost / type_traits / is_pod.hpp
1
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).
6 //
7 //  See http://www.boost.org/libs/type_traits for most recent version including documentation.
8
9 #ifndef BOOST_TT_IS_POD_HPP_INCLUDED
10 #define BOOST_TT_IS_POD_HPP_INCLUDED
11
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>
17
18 #include <cstddef>
19
20 // should be the last #include
21 #include <boost/type_traits/detail/bool_trait_def.hpp>
22
23 #ifndef BOOST_IS_POD
24 #define BOOST_INTERNAL_IS_POD(T) false
25 #else
26 #define BOOST_INTERNAL_IS_POD(T) BOOST_IS_POD(T)
27 #endif
28
29 namespace boost {
30
31 // forward declaration, needed by 'is_pod_array_helper' template below
32 template< typename T > struct is_POD;
33
34 namespace detail {
35
36 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
37
38 template <typename T> struct is_pod_impl
39
40     BOOST_STATIC_CONSTANT(
41         bool, value =
42         (::boost::type_traits::ice_or<
43             ::boost::is_scalar<T>::value,
44             ::boost::is_void<T>::value,
45             BOOST_INTERNAL_IS_POD(T)
46          >::value));
47 };
48
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>
53 {
54 };
55 #endif
56
57 #else
58
59 template <bool is_array = false>
60 struct is_pod_helper
61 {
62     template <typename T> struct result_
63     {
64         BOOST_STATIC_CONSTANT(
65             bool, value =
66             (::boost::type_traits::ice_or<
67                 ::boost::is_scalar<T>::value,
68                 ::boost::is_void<T>::value,
69                 BOOST_INTERNAL_IS_POD(T)
70             >::value));
71     };
72 };
73
74 template <bool b>
75 struct bool_to_yes_no_type
76 {
77     typedef ::boost::type_traits::no_type type;
78 };
79
80 template <>
81 struct bool_to_yes_no_type<true>
82 {
83     typedef ::boost::type_traits::yes_type type;
84 };
85
86 template <typename ArrayType>
87 struct is_pod_array_helper
88 {
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;
92 };
93
94 template <typename T>
95 is_pod_array_helper<T> is_POD_array(T*);
96
97 template <>
98 struct is_pod_helper<true>
99 {
100     template <typename T> struct result_
101     {
102         static T& help();
103         BOOST_STATIC_CONSTANT(bool, value =
104             sizeof(is_POD_array(help()).instance()) == sizeof(::boost::type_traits::yes_type)
105             );
106     };
107 };
108
109
110 template <typename T> struct is_pod_impl
111
112    BOOST_STATIC_CONSTANT(
113        bool, value = (
114            ::boost::detail::is_pod_helper<
115               ::boost::is_array<T>::value
116            >::template result_<T>::value
117            )
118        );
119 };
120
121 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
122
123 // the following help compilers without partial specialization support:
124 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void,true)
125
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)
130 #endif
131
132 } // namespace detail
133
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)
138
139 } // namespace boost
140
141 #include <boost/type_traits/detail/bool_trait_undef.hpp>
142
143 #undef BOOST_INTERNAL_IS_POD
144
145 #endif // BOOST_TT_IS_POD_HPP_INCLUDED