]> git.donarmstrong.com Git - rsem.git/blob - boost/type_traits/is_empty.hpp
Added error detection for cases such as a read's two mates having different names...
[rsem.git] / 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/ice_or.hpp>
14 #include <boost/type_traits/config.hpp>
15 #include <boost/type_traits/intrinsics.hpp>
16
17 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
18 #   include <boost/type_traits/remove_cv.hpp>
19 #   include <boost/type_traits/is_class.hpp>
20 #   include <boost/type_traits/add_reference.hpp>
21 #else
22 #   include <boost/type_traits/is_reference.hpp>
23 #   include <boost/type_traits/is_pointer.hpp>
24 #   include <boost/type_traits/is_member_pointer.hpp>
25 #   include <boost/type_traits/is_array.hpp>
26 #   include <boost/type_traits/is_void.hpp>
27 #   include <boost/type_traits/detail/ice_and.hpp>
28 #   include <boost/type_traits/detail/ice_not.hpp>
29 #endif
30
31 // should be always the last #include directive
32 #include <boost/type_traits/detail/bool_trait_def.hpp>
33
34 #ifndef BOOST_INTERNAL_IS_EMPTY
35 #define BOOST_INTERNAL_IS_EMPTY(T) false
36 #else
37 #define BOOST_INTERNAL_IS_EMPTY(T) BOOST_IS_EMPTY(T)
38 #endif
39
40 namespace boost {
41
42 namespace detail {
43
44 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
45
46 #ifdef BOOST_MSVC
47 #pragma warning(push)
48 #pragma warning(disable:4624) // destructor could not be generated
49 #endif
50
51 template <typename T>
52 struct empty_helper_t1 : public T
53 {
54     empty_helper_t1();  // hh compiler bug workaround
55     int i[256];
56 private:
57    // suppress compiler warnings:
58    empty_helper_t1(const empty_helper_t1&);
59    empty_helper_t1& operator=(const empty_helper_t1&);
60 };
61
62 #ifdef BOOST_MSVC
63 #pragma warning(pop)
64 #endif
65
66 struct empty_helper_t2 { int i[256]; };
67
68 #if !BOOST_WORKAROUND(__BORLANDC__, < 0x600)
69
70 template <typename T, bool is_a_class = false>
71 struct empty_helper
72 {
73     BOOST_STATIC_CONSTANT(bool, value = false);
74 };
75
76 template <typename T>
77 struct empty_helper<T, true>
78 {
79     BOOST_STATIC_CONSTANT(
80         bool, value = (sizeof(empty_helper_t1<T>) == sizeof(empty_helper_t2))
81         );
82 };
83
84 template <typename T>
85 struct is_empty_impl
86 {
87     typedef typename remove_cv<T>::type cvt;
88     BOOST_STATIC_CONSTANT(
89         bool, value = (
90             ::boost::type_traits::ice_or<
91               ::boost::detail::empty_helper<cvt,::boost::is_class<T>::value>::value
92               , BOOST_INTERNAL_IS_EMPTY(cvt)
93             >::value
94             ));
95 };
96
97 #else // __BORLANDC__
98
99 template <typename T, bool is_a_class, bool convertible_to_int>
100 struct empty_helper
101 {
102     BOOST_STATIC_CONSTANT(bool, value = false);
103 };
104
105 template <typename T>
106 struct empty_helper<T, true, false>
107 {
108     BOOST_STATIC_CONSTANT(bool, value = (
109         sizeof(empty_helper_t1<T>) == sizeof(empty_helper_t2)
110         ));
111 };
112
113 template <typename T>
114 struct is_empty_impl
115 {
116    typedef typename remove_cv<T>::type cvt;
117    typedef typename add_reference<T>::type r_type;
118
119    BOOST_STATIC_CONSTANT(
120        bool, value = (
121            ::boost::type_traits::ice_or<
122               ::boost::detail::empty_helper<
123                   cvt
124                 , ::boost::is_class<T>::value
125                 , ::boost::is_convertible< r_type,int>::value
126               >::value
127               , BOOST_INTERNAL_IS_EMPTY(cvt)
128            >::value));
129 };
130
131 #endif // __BORLANDC__
132
133 #else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
134
135 #ifdef BOOST_MSVC6_MEMBER_TEMPLATES
136
137 template <typename T>
138 struct empty_helper_t1 : public T
139 {
140    empty_helper_t1();
141    int i[256];
142 };
143
144 struct empty_helper_t2 { int i[256]; };
145
146 template <typename T>
147 struct empty_helper_base
148 {
149    enum { value = (sizeof(empty_helper_t1<T>) == sizeof(empty_helper_t2)) };
150 };
151
152 template <typename T>
153 struct empty_helper_nonbase
154 {
155    enum { value = false };
156 };
157
158 template <bool base>
159 struct empty_helper_chooser
160 {
161    template <typename T> struct result_
162    {
163       typedef empty_helper_nonbase<T> type;
164    };
165 };
166
167 template <>
168 struct empty_helper_chooser<true>
169 {
170    template <typename T> struct result_
171    {
172       typedef empty_helper_base<T> type;
173    };
174 };
175
176 template <typename T>
177 struct is_empty_impl
178 {
179    typedef ::boost::detail::empty_helper_chooser<
180       ::boost::type_traits::ice_and<
181          ::boost::type_traits::ice_not< ::boost::is_reference<T>::value >::value,
182          ::boost::type_traits::ice_not< ::boost::is_convertible<T,double>::value >::value,
183          ::boost::type_traits::ice_not< ::boost::is_pointer<T>::value >::value,
184          ::boost::type_traits::ice_not< ::boost::is_member_pointer<T>::value >::value,
185          ::boost::type_traits::ice_not< ::boost::is_array<T>::value >::value,
186          ::boost::type_traits::ice_not< ::boost::is_void<T>::value >::value,
187          ::boost::type_traits::ice_not<
188             ::boost::is_convertible<T,void const volatile*>::value
189             >::value
190       >::value > chooser;
191
192    typedef typename chooser::template result_<T> result;
193    typedef typename result::type eh_type;
194
195    BOOST_STATIC_CONSTANT(bool, value =
196       (::boost::type_traits::ice_or<eh_type::value, BOOST_INTERNAL_IS_EMPTY(T)>::value));
197 };
198
199 #else
200
201 template <typename T> struct is_empty_impl
202 {
203     BOOST_STATIC_CONSTANT(bool, value = BOOST_INTERNAL_IS_EMPTY(T));
204 };
205
206 #endif  // BOOST_MSVC6_MEMBER_TEMPLATES
207
208 #endif  // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
209
210 // these help when the compiler has no partial specialization support:
211 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_empty,void,false)
212 #ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
213 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_empty,void const,false)
214 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_empty,void volatile,false)
215 BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_empty,void const volatile,false)
216 #endif
217
218 } // namespace detail
219
220 BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_empty,T,::boost::detail::is_empty_impl<T>::value)
221
222 } // namespace boost
223
224 #include <boost/type_traits/detail/bool_trait_undef.hpp>
225
226 #undef BOOST_INTERNAL_IS_EMPTY
227
228 #endif // BOOST_TT_IS_EMPTY_HPP_INCLUDED
229