blob: 2d462cd120f65c271f545992bd94f303d83d5fc5 [file] [log] [blame]
Jeff Thompsonf7d49942013-08-01 16:47:40 -07001
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
Jeff Thompson2277ce52013-08-01 17:34:11 -070012#include <ndnboost/type_traits/config.hpp>
13#include <ndnboost/type_traits/is_void.hpp>
14#include <ndnboost/type_traits/is_scalar.hpp>
15#include <ndnboost/type_traits/detail/ice_or.hpp>
16#include <ndnboost/type_traits/intrinsics.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070017
18#include <cstddef>
19
20// should be the last #include
Jeff Thompson2277ce52013-08-01 17:34:11 -070021#include <ndnboost/type_traits/detail/bool_trait_def.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070022
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
29namespace ndnboost {
30
31// forward declaration, needed by 'is_pod_array_helper' template below
32template< typename T > struct is_POD;
33
34namespace detail {
35
36#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
37
38template <typename T> struct is_pod_impl
39{
40 BOOST_STATIC_CONSTANT(
41 bool, value =
42 (::ndnboost::type_traits::ice_or<
43 ::ndnboost::is_scalar<T>::value,
44 ::ndnboost::is_void<T>::value,
45 BOOST_INTERNAL_IS_POD(T)
46 >::value));
47};
48
49#if !defined(BOOST_NO_ARRAY_TYPE_SPECIALIZATIONS)
50template <typename T, std::size_t sz>
51struct is_pod_impl<T[sz]>
52 : public is_pod_impl<T>
53{
54};
55#endif
56
57#else
58
59template <bool is_array = false>
60struct is_pod_helper
61{
62 template <typename T> struct result_
63 {
64 BOOST_STATIC_CONSTANT(
65 bool, value =
66 (::ndnboost::type_traits::ice_or<
67 ::ndnboost::is_scalar<T>::value,
68 ::ndnboost::is_void<T>::value,
69 BOOST_INTERNAL_IS_POD(T)
70 >::value));
71 };
72};
73
74template <bool b>
75struct bool_to_yes_no_type
76{
77 typedef ::ndnboost::type_traits::no_type type;
78};
79
80template <>
81struct bool_to_yes_no_type<true>
82{
83 typedef ::ndnboost::type_traits::yes_type type;
84};
85
86template <typename ArrayType>
87struct is_pod_array_helper
88{
89 enum { is_pod = ::ndnboost::is_POD<ArrayType>::value }; // MSVC workaround
90 typedef typename bool_to_yes_no_type<is_pod>::type type;
91 type instance() const;
92};
93
94template <typename T>
95is_pod_array_helper<T> is_POD_array(T*);
96
97template <>
98struct 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(::ndnboost::type_traits::yes_type)
105 );
106 };
107};
108
109
110template <typename T> struct is_pod_impl
111{
112 BOOST_STATIC_CONSTANT(
113 bool, value = (
114 ::ndnboost::detail::is_pod_helper<
115 ::ndnboost::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:
124BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void,true)
125
126#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
127BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void const,true)
128BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void volatile,true)
129BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void const volatile,true)
130#endif
131
132} // namespace detail
133
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700134BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pod,T,::ndnboost::detail::is_pod_impl<T>::value)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700135// is_POD is the old depricated name for this trait, do not use this as it may
136// be removed in future without warning!!
137BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_POD,T,::ndnboost::is_pod<T>::value)
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700138
139} // namespace ndnboost
140
Jeff Thompson2277ce52013-08-01 17:34:11 -0700141#include <ndnboost/type_traits/detail/bool_trait_undef.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -0700142
143#undef BOOST_INTERNAL_IS_POD
144
145#endif // BOOST_TT_IS_POD_HPP_INCLUDED