~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to boost/boost/type_traits/is_pod.hpp

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
 
3
// Permission to copy, use, modify, sell and distribute this software is 
 
4
// granted provided this copyright notice appears in all copies. This software 
 
5
// is provided "as is" without express or implied warranty, and with no claim 
 
6
// as to its suitability for any purpose.
 
7
//
 
8
// See http://www.boost.org for most recent version including documentation.
 
9
 
 
10
#ifndef BOOST_TT_IS_POD_HPP_INCLUDED
 
11
#define BOOST_TT_IS_POD_HPP_INCLUDED
 
12
 
 
13
#include "boost/type_traits/config.hpp"
 
14
#include "boost/type_traits/is_void.hpp"
 
15
#include "boost/type_traits/is_scalar.hpp"
 
16
#include "boost/type_traits/detail/ice_or.hpp"
 
17
#include "boost/type_traits/intrinsics.hpp"
 
18
 
 
19
#include <cstddef>
 
20
 
 
21
// should be the last #include
 
22
#include "boost/type_traits/detail/bool_trait_def.hpp"
 
23
 
 
24
namespace boost {
 
25
 
 
26
// forward declaration, needed by 'is_pod_array_helper' template below
 
27
template< typename T > struct is_POD;
 
28
 
 
29
namespace detail {
 
30
 
 
31
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
 
32
 
 
33
template <typename T> struct is_pod_impl
 
34
 
35
    BOOST_STATIC_CONSTANT(
 
36
        bool, value =
 
37
        (::boost::type_traits::ice_or<
 
38
            ::boost::is_scalar<T>::value,
 
39
            ::boost::is_void<T>::value,
 
40
            BOOST_IS_POD(T)
 
41
         >::value));
 
42
};
 
43
 
 
44
template <typename T, std::size_t sz>
 
45
struct is_pod_impl<T[sz]>
 
46
    : is_pod_impl<T>
 
47
{
 
48
};
 
49
 
 
50
#else
 
51
 
 
52
template <bool is_array = false>
 
53
struct is_pod_helper
 
54
{
 
55
    template <typename T> struct result_
 
56
    {
 
57
        BOOST_STATIC_CONSTANT(
 
58
            bool, value =
 
59
            (::boost::type_traits::ice_or<
 
60
                ::boost::is_scalar<T>::value,
 
61
                ::boost::is_void<T>::value,
 
62
                BOOST_IS_POD(T)
 
63
            >::value));
 
64
    };
 
65
};
 
66
 
 
67
template <bool b>
 
68
struct bool_to_yes_no_type
 
69
{
 
70
    typedef ::boost::type_traits::no_type type;
 
71
};
 
72
 
 
73
template <>
 
74
struct bool_to_yes_no_type<true>
 
75
{
 
76
    typedef ::boost::type_traits::yes_type type;
 
77
};
 
78
 
 
79
template <typename ArrayType>
 
80
struct is_pod_array_helper
 
81
{
 
82
    enum { is_pod = ::boost::is_POD<ArrayType>::value }; // MSVC workaround
 
83
    typedef typename bool_to_yes_no_type<is_pod>::type type;
 
84
    type instance() const;
 
85
};
 
86
 
 
87
template <typename T>
 
88
is_pod_array_helper<T> is_POD_array(T*);
 
89
 
 
90
template <>
 
91
struct is_pod_helper<true>
 
92
{
 
93
    template <typename T> struct result_
 
94
    {
 
95
        static T& help();
 
96
        BOOST_STATIC_CONSTANT(bool, value =
 
97
            sizeof(is_POD_array(help()).instance()) == sizeof(::boost::type_traits::yes_type)
 
98
            );
 
99
    };
 
100
};
 
101
 
 
102
 
 
103
template <typename T> struct is_pod_impl
 
104
 
105
   BOOST_STATIC_CONSTANT(
 
106
       bool, value = (
 
107
           ::boost::detail::is_pod_helper<
 
108
              ::boost::is_array<T>::value
 
109
           >::template result_<T>::value
 
110
           )
 
111
       );
 
112
};
 
113
 
 
114
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
 
115
 
 
116
// the following help compilers without partial specialization support:
 
117
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void,true)
 
118
 
 
119
#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
 
120
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void const,true)
 
121
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void volatile,true)
 
122
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_pod,void const volatile,true)
 
123
#endif
 
124
 
 
125
} // namespace detail
 
126
 
 
127
BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_POD,T,::boost::detail::is_pod_impl<T>::value)
 
128
BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pod,T,::boost::is_POD<T>::value)
 
129
 
 
130
} // namespace boost
 
131
 
 
132
#include "boost/type_traits/detail/bool_trait_undef.hpp"
 
133
 
 
134
#endif // BOOST_TT_IS_POD_HPP_INCLUDED