]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_traits/include/boost/type_traits/is_empty.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / type_traits / include / boost / type_traits / is_empty.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_EMPTY_HPP_INCLUDED
10 #define BOOST_TT_IS_EMPTY_HPP_INCLUDED
11
12 #include <boost/type_traits/is_convertible.hpp>
13 #include <boost/type_traits/detail/config.hpp>
14 #include <boost/type_traits/intrinsics.hpp>
15
16 #include <boost/type_traits/remove_cv.hpp>
17 #include <boost/type_traits/is_class.hpp>
18 #include <boost/type_traits/add_reference.hpp>
19
20 #ifndef BOOST_INTERNAL_IS_EMPTY
21 #define BOOST_INTERNAL_IS_EMPTY(T) false
22 #else
23 #define BOOST_INTERNAL_IS_EMPTY(T) BOOST_IS_EMPTY(T)
24 #endif
25
26 namespace boost {
27
28 namespace detail {
29
30
31 #ifdef BOOST_MSVC
32 #pragma warning(push)
33 #pragma warning(disable:4624) // destructor could not be generated
34 #endif
35
36 template <typename T>
37 struct empty_helper_t1 : public T
38 {
39 empty_helper_t1(); // hh compiler bug workaround
40 int i[256];
41 private:
42 // suppress compiler warnings:
43 empty_helper_t1(const empty_helper_t1&);
44 empty_helper_t1& operator=(const empty_helper_t1&);
45 };
46
47 #ifdef BOOST_MSVC
48 #pragma warning(pop)
49 #endif
50
51 struct empty_helper_t2 { int i[256]; };
52
53 #if !BOOST_WORKAROUND(__BORLANDC__, < 0x600)
54
55 template <typename T, bool is_a_class = false>
56 struct empty_helper
57 {
58 BOOST_STATIC_CONSTANT(bool, value = false);
59 };
60
61 template <typename T>
62 struct empty_helper<T, true>
63 {
64 BOOST_STATIC_CONSTANT(
65 bool, value = (sizeof(empty_helper_t1<T>) == sizeof(empty_helper_t2))
66 );
67 };
68
69 template <typename T>
70 struct is_empty_impl
71 {
72 typedef typename remove_cv<T>::type cvt;
73 BOOST_STATIC_CONSTANT(
74 bool,
75 value = ( ::boost::detail::empty_helper<cvt,::boost::is_class<T>::value>::value || BOOST_INTERNAL_IS_EMPTY(cvt)));
76 };
77
78 #else // __BORLANDC__
79
80 template <typename T, bool is_a_class, bool convertible_to_int>
81 struct empty_helper
82 {
83 BOOST_STATIC_CONSTANT(bool, value = false);
84 };
85
86 template <typename T>
87 struct empty_helper<T, true, false>
88 {
89 BOOST_STATIC_CONSTANT(bool, value = (
90 sizeof(empty_helper_t1<T>) == sizeof(empty_helper_t2)
91 ));
92 };
93
94 template <typename T>
95 struct is_empty_impl
96 {
97 typedef typename remove_cv<T>::type cvt;
98 typedef typename add_reference<T>::type r_type;
99
100 BOOST_STATIC_CONSTANT(
101 bool, value = (
102 ::boost::detail::empty_helper<
103 cvt
104 , ::boost::is_class<T>::value
105 , ::boost::is_convertible< r_type,int>::value
106 >::value || BOOST_INTERNAL_IS_EMPTY(cvt));
107 };
108
109 #endif // __BORLANDC__
110
111 } // namespace detail
112
113 template <class T> struct is_empty : integral_constant<bool, ::boost::detail::is_empty_impl<T>::value> {};
114
115 } // namespace boost
116
117 #undef BOOST_INTERNAL_IS_EMPTY
118
119 #endif // BOOST_TT_IS_EMPTY_HPP_INCLUDED
120