]> git.donarmstrong.com Git - rsem.git/blob - boost/type_traits/is_pod.hpp
af2c3c4aeb05b9117c4c723890c10f2c079fa082
[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 namespace boost {
24
25 // forward declaration, needed by 'is_pod_array_helper' template below
26 template< typename T > struct is_POD;
27
28 namespace detail {
29
30 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
31
32 template <typename T> struct is_pod_impl
33
34     BOOST_STATIC_CONSTANT(
35         bool, value =
36         (::boost::type_traits::ice_or<
37             ::boost::is_scalar<T>::value,
38             ::boost::is_void<T>::value,
39             BOOST_IS_POD(T)
40          >::value));
41 };
42
43 #if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
44 template <typename T, std::size_t sz>
45 struct is_pod_impl<T[sz]>
46     : is_pod_impl<T>
47 {
48 };
49 #endif
50
51 #else
52
53 template <bool is_array = false>
54 struct is_pod_helper
55 {
56     template <typename T> struct result_
57     {
58         BOOST_STATIC_CONSTANT(
59             bool, value =
60             (::boost::type_traits::ice_or<
61                 ::boost::is_scalar<T>::value,
62                 ::boost::is_void<T>::value,
63                 BOOST_IS_POD(T)
64             >::value));
65     };
66 };
67
68 template <bool b>
69 struct bool_to_yes_no_type
70 {
71     typedef ::boost::type_traits::no_type type;
72 };
73
74 template <>
75 struct bool_to_yes_no_type<true>
76 {
77     typedef ::boost::type_traits::yes_type type;
78 };
79
80 template <typename ArrayType>
81 struct is_pod_array_helper
82 {
83     enum { is_pod = ::boost::is_POD<ArrayType>::value }; // MSVC workaround
84     typedef typename bool_to_yes_no_type<is_pod>::type type;
85     type instance() const;
86 };
87
88 template <typename T>
89 is_pod_array_helper<T> is_POD_array(T*);
90
91 template <>
92 struct is_pod_helper<true>
93 {
94     template <typename T> struct result_
95     {
96         static T& help();
97         BOOST_STATIC_CONSTANT(bool, value =
98             sizeof(is_POD_array(help()).instance()) == sizeof(::boost::type_traits::yes_type)
99             );
100     };
101 };
102
103
104 template <typename T> struct is_pod_impl
105
106    BOOST_STATIC_CONSTANT(
107        bool, value = (
108            ::boost::detail::is_pod_helper<
109               ::boost::is_array<T>::value
110            >::template result_<T>::value
111            )
112        );
113 };
114
115 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
116
117 // the following help compilers without partial specialization support:
118 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void,true)
119
120 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
121 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void const,true)
122 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void volatile,true)
123 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void const volatile,true)
124 #endif
125
126 } // namespace detail
127
128 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_POD,T,::boost::detail::is_pod_impl<T>::value)
129 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pod,T,::boost::detail::is_pod_impl<T>::value)
130
131 } // namespace boost
132
133 #include <boost/type_traits/detail/bool_trait_undef.hpp>
134
135 #endif // BOOST_TT_IS_POD_HPP_INCLUDED