fix doc example typo
[boost.git] / boost / type_traits / is_pod.hpp
blobaf2c3c4aeb05b9117c4c723890c10f2c079fa082
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.
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>
18 #include <cstddef>
20 // should be the last #include
21 #include <boost/type_traits/detail/bool_trait_def.hpp>
23 namespace boost {
25 // forward declaration, needed by 'is_pod_array_helper' template below
26 template< typename T > struct is_POD;
28 namespace detail {
30 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
32 template <typename T> struct is_pod_impl
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));
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>
49 #endif
51 #else
53 template <bool is_array = false>
54 struct is_pod_helper
56 template <typename T> struct result_
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));
68 template <bool b>
69 struct bool_to_yes_no_type
71 typedef ::boost::type_traits::no_type type;
74 template <>
75 struct bool_to_yes_no_type<true>
77 typedef ::boost::type_traits::yes_type type;
80 template <typename ArrayType>
81 struct is_pod_array_helper
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;
88 template <typename T>
89 is_pod_array_helper<T> is_POD_array(T*);
91 template <>
92 struct is_pod_helper<true>
94 template <typename T> struct result_
96 static T& help();
97 BOOST_STATIC_CONSTANT(bool, value =
98 sizeof(is_POD_array(help()).instance()) == sizeof(::boost::type_traits::yes_type)
104 template <typename T> struct is_pod_impl
106 BOOST_STATIC_CONSTANT(
107 bool, value = (
108 ::boost::detail::is_pod_helper<
109 ::boost::is_array<T>::value
110 >::template result_<T>::value
115 #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
117 // the following help compilers without partial specialization support:
118 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void,true)
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
126 } // namespace detail
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)
131 } // namespace boost
133 #include <boost/type_traits/detail/bool_trait_undef.hpp>
135 #endif // BOOST_TT_IS_POD_HPP_INCLUDED