annotate DEPENDENCIES/generic/include/boost/intrusive/detail/mpl.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
rev   line source
Chris@16 1 /////////////////////////////////////////////////////////////////////////////
Chris@16 2 //
Chris@16 3 // (C) Copyright Ion Gaztanaga 2006-2013
Chris@16 4 //
Chris@16 5 // Distributed under the Boost Software License, Version 1.0.
Chris@16 6 // (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 //
Chris@16 9 // See http://www.boost.org/libs/intrusive for documentation.
Chris@16 10 //
Chris@16 11 /////////////////////////////////////////////////////////////////////////////
Chris@16 12
Chris@16 13 #ifndef BOOST_INTRUSIVE_DETAIL_MPL_HPP
Chris@16 14 #define BOOST_INTRUSIVE_DETAIL_MPL_HPP
Chris@16 15
Chris@16 16 #include <boost/intrusive/detail/config_begin.hpp>
Chris@16 17 #include <cstddef>
Chris@16 18
Chris@16 19 namespace boost {
Chris@16 20 namespace intrusive {
Chris@16 21 namespace detail {
Chris@16 22
Chris@16 23 typedef char one;
Chris@16 24 struct two {one _[2];};
Chris@16 25
Chris@16 26 template< bool C_ >
Chris@16 27 struct bool_
Chris@16 28 {
Chris@16 29 static const bool value = C_;
Chris@16 30 };
Chris@16 31
Chris@16 32 typedef bool_<true> true_;
Chris@16 33 typedef bool_<false> false_;
Chris@16 34
Chris@16 35 typedef true_ true_type;
Chris@16 36 typedef false_ false_type;
Chris@16 37
Chris@16 38 typedef char yes_type;
Chris@16 39 struct no_type
Chris@16 40 {
Chris@16 41 char padding[8];
Chris@16 42 };
Chris@16 43
Chris@16 44 template <bool B, class T = void>
Chris@16 45 struct enable_if_c {
Chris@16 46 typedef T type;
Chris@16 47 };
Chris@16 48
Chris@16 49 template <class T>
Chris@16 50 struct enable_if_c<false, T> {};
Chris@16 51
Chris@16 52 template <class Cond, class T = void>
Chris@16 53 struct enable_if : public enable_if_c<Cond::value, T>{};
Chris@16 54
Chris@16 55 template<class F, class Param>
Chris@16 56 struct apply
Chris@16 57 {
Chris@16 58 typedef typename F::template apply<Param>::type type;
Chris@16 59 };
Chris@16 60
Chris@16 61 template <class T, class U>
Chris@16 62 class is_convertible
Chris@16 63 {
Chris@16 64 typedef char true_t;
Chris@16 65 class false_t { char dummy[2]; };
Chris@16 66 static true_t dispatch(U);
Chris@16 67 static false_t dispatch(...);
Chris@16 68 static const T &trigger();
Chris@16 69 public:
Chris@16 70 static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t);
Chris@16 71 };
Chris@16 72
Chris@16 73 template<
Chris@16 74 bool C
Chris@16 75 , typename T1
Chris@16 76 , typename T2
Chris@16 77 >
Chris@16 78 struct if_c
Chris@16 79 {
Chris@16 80 typedef T1 type;
Chris@16 81 };
Chris@16 82
Chris@16 83 template<
Chris@16 84 typename T1
Chris@16 85 , typename T2
Chris@16 86 >
Chris@16 87 struct if_c<false,T1,T2>
Chris@16 88 {
Chris@16 89 typedef T2 type;
Chris@16 90 };
Chris@16 91
Chris@16 92 template<
Chris@16 93 typename C
Chris@16 94 , typename T1
Chris@16 95 , typename T2
Chris@16 96 >
Chris@16 97 struct if_
Chris@16 98 {
Chris@16 99 typedef typename if_c<0 != C::value, T1, T2>::type type;
Chris@16 100 };
Chris@16 101
Chris@16 102 template<
Chris@16 103 bool C
Chris@16 104 , typename F1
Chris@16 105 , typename F2
Chris@16 106 >
Chris@16 107 struct eval_if_c
Chris@16 108 : if_c<C,F1,F2>::type
Chris@16 109 {};
Chris@16 110
Chris@16 111 template<
Chris@16 112 typename C
Chris@16 113 , typename T1
Chris@16 114 , typename T2
Chris@16 115 >
Chris@16 116 struct eval_if
Chris@16 117 : if_<C,T1,T2>::type
Chris@16 118 {};
Chris@16 119
Chris@16 120 // identity is an extension: it is not part of the standard.
Chris@16 121 template <class T>
Chris@16 122 struct identity
Chris@16 123 {
Chris@16 124 typedef T type;
Chris@16 125 };
Chris@16 126
Chris@16 127 #if defined(BOOST_MSVC) || defined(__BORLANDC_)
Chris@16 128 #define BOOST_INTRUSIVE_TT_DECL __cdecl
Chris@16 129 #else
Chris@16 130 #define BOOST_INTRUSIVE_TT_DECL
Chris@16 131 #endif
Chris@16 132
Chris@16 133 #if defined(_MSC_EXTENSIONS) && !defined(__BORLAND__) && !defined(_WIN64) && !defined(UNDER_CE)
Chris@16 134 #define BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
Chris@16 135 #endif
Chris@16 136
Chris@16 137 template <typename T>
Chris@16 138 struct is_unary_or_binary_function_impl
Chris@16 139 { static const bool value = false; };
Chris@16 140
Chris@16 141 // see boost ticket #4094
Chris@16 142 // avoid duplicate definitions of is_unary_or_binary_function_impl
Chris@16 143 #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
Chris@16 144
Chris@16 145 template <typename R>
Chris@16 146 struct is_unary_or_binary_function_impl<R (*)()>
Chris@16 147 { static const bool value = true; };
Chris@16 148
Chris@16 149 template <typename R>
Chris@16 150 struct is_unary_or_binary_function_impl<R (*)(...)>
Chris@16 151 { static const bool value = true; };
Chris@16 152
Chris@16 153 #else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
Chris@16 154
Chris@16 155 template <typename R>
Chris@16 156 struct is_unary_or_binary_function_impl<R (__stdcall*)()>
Chris@16 157 { static const bool value = true; };
Chris@16 158
Chris@16 159 #ifndef _MANAGED
Chris@16 160
Chris@16 161 template <typename R>
Chris@16 162 struct is_unary_or_binary_function_impl<R (__fastcall*)()>
Chris@16 163 { static const bool value = true; };
Chris@16 164
Chris@16 165 #endif
Chris@16 166
Chris@16 167 template <typename R>
Chris@16 168 struct is_unary_or_binary_function_impl<R (__cdecl*)()>
Chris@16 169 { static const bool value = true; };
Chris@16 170
Chris@16 171 template <typename R>
Chris@16 172 struct is_unary_or_binary_function_impl<R (__cdecl*)(...)>
Chris@16 173 { static const bool value = true; };
Chris@16 174
Chris@16 175 #endif
Chris@16 176
Chris@16 177 // see boost ticket #4094
Chris@16 178 // avoid duplicate definitions of is_unary_or_binary_function_impl
Chris@16 179 #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
Chris@16 180
Chris@16 181 template <typename R, class T0>
Chris@16 182 struct is_unary_or_binary_function_impl<R (*)(T0)>
Chris@16 183 { static const bool value = true; };
Chris@16 184
Chris@16 185 template <typename R, class T0>
Chris@16 186 struct is_unary_or_binary_function_impl<R (*)(T0...)>
Chris@16 187 { static const bool value = true; };
Chris@16 188
Chris@16 189 #else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
Chris@16 190
Chris@16 191 template <typename R, class T0>
Chris@16 192 struct is_unary_or_binary_function_impl<R (__stdcall*)(T0)>
Chris@16 193 { static const bool value = true; };
Chris@16 194
Chris@16 195 #ifndef _MANAGED
Chris@16 196
Chris@16 197 template <typename R, class T0>
Chris@16 198 struct is_unary_or_binary_function_impl<R (__fastcall*)(T0)>
Chris@16 199 { static const bool value = true; };
Chris@16 200
Chris@16 201 #endif
Chris@16 202
Chris@16 203 template <typename R, class T0>
Chris@16 204 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0)>
Chris@16 205 { static const bool value = true; };
Chris@16 206
Chris@16 207 template <typename R, class T0>
Chris@16 208 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0...)>
Chris@16 209 { static const bool value = true; };
Chris@16 210
Chris@16 211 #endif
Chris@16 212
Chris@16 213 // see boost ticket #4094
Chris@16 214 // avoid duplicate definitions of is_unary_or_binary_function_impl
Chris@16 215 #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
Chris@16 216
Chris@16 217 template <typename R, class T0, class T1>
Chris@16 218 struct is_unary_or_binary_function_impl<R (*)(T0, T1)>
Chris@16 219 { static const bool value = true; };
Chris@16 220
Chris@16 221 template <typename R, class T0, class T1>
Chris@16 222 struct is_unary_or_binary_function_impl<R (*)(T0, T1...)>
Chris@16 223 { static const bool value = true; };
Chris@16 224
Chris@16 225 #else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS
Chris@16 226
Chris@16 227 template <typename R, class T0, class T1>
Chris@16 228 struct is_unary_or_binary_function_impl<R (__stdcall*)(T0, T1)>
Chris@16 229 { static const bool value = true; };
Chris@16 230
Chris@16 231 #ifndef _MANAGED
Chris@16 232
Chris@16 233 template <typename R, class T0, class T1>
Chris@16 234 struct is_unary_or_binary_function_impl<R (__fastcall*)(T0, T1)>
Chris@16 235 { static const bool value = true; };
Chris@16 236
Chris@16 237 #endif
Chris@16 238
Chris@16 239 template <typename R, class T0, class T1>
Chris@16 240 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0, T1)>
Chris@16 241 { static const bool value = true; };
Chris@16 242
Chris@16 243 template <typename R, class T0, class T1>
Chris@16 244 struct is_unary_or_binary_function_impl<R (__cdecl*)(T0, T1...)>
Chris@16 245 { static const bool value = true; };
Chris@16 246 #endif
Chris@16 247
Chris@16 248 template <typename T>
Chris@16 249 struct is_unary_or_binary_function_impl<T&>
Chris@16 250 { static const bool value = false; };
Chris@16 251
Chris@16 252 template<typename T>
Chris@16 253 struct is_unary_or_binary_function
Chris@16 254 { static const bool value = is_unary_or_binary_function_impl<T>::value; };
Chris@16 255
Chris@16 256 //boost::alignment_of yields to 10K lines of preprocessed code, so we
Chris@16 257 //need an alternative
Chris@16 258 template <typename T> struct alignment_of;
Chris@16 259
Chris@16 260 template <typename T>
Chris@16 261 struct alignment_of_hack
Chris@16 262 {
Chris@16 263 char c;
Chris@16 264 T t;
Chris@16 265 alignment_of_hack();
Chris@16 266 };
Chris@16 267
Chris@16 268 template <unsigned A, unsigned S>
Chris@16 269 struct alignment_logic
Chris@16 270 {
Chris@16 271 static const std::size_t value = A < S ? A : S;
Chris@16 272 };
Chris@16 273
Chris@16 274 template< typename T >
Chris@16 275 struct alignment_of
Chris@16 276 {
Chris@16 277 static const std::size_t value = alignment_logic
Chris@16 278 < sizeof(alignment_of_hack<T>) - sizeof(T)
Chris@16 279 , sizeof(T)
Chris@16 280 >::value;
Chris@16 281 };
Chris@16 282
Chris@16 283 template <typename T, typename U>
Chris@16 284 struct is_same
Chris@16 285 {
Chris@16 286 static const bool value = false;
Chris@16 287 };
Chris@16 288
Chris@16 289 template <typename T>
Chris@16 290 struct is_same<T, T>
Chris@16 291 {
Chris@16 292 static const bool value = true;
Chris@16 293 };
Chris@16 294
Chris@16 295 template<typename T>
Chris@16 296 struct add_const
Chris@16 297 { typedef const T type; };
Chris@16 298
Chris@16 299 template<typename T>
Chris@16 300 struct remove_const
Chris@16 301 { typedef T type; };
Chris@16 302
Chris@16 303 template<typename T>
Chris@16 304 struct remove_const<const T>
Chris@16 305 { typedef T type; };
Chris@16 306
Chris@16 307 template<typename T>
Chris@16 308 struct remove_cv
Chris@16 309 { typedef T type; };
Chris@16 310
Chris@16 311 template<typename T>
Chris@16 312 struct remove_cv<const T>
Chris@16 313 { typedef T type; };
Chris@16 314
Chris@16 315 template<typename T>
Chris@16 316 struct remove_cv<const volatile T>
Chris@16 317 { typedef T type; };
Chris@16 318
Chris@16 319 template<typename T>
Chris@16 320 struct remove_cv<volatile T>
Chris@16 321 { typedef T type; };
Chris@16 322
Chris@16 323 template<class T>
Chris@16 324 struct remove_reference
Chris@16 325 {
Chris@16 326 typedef T type;
Chris@16 327 };
Chris@16 328
Chris@16 329 template<class T>
Chris@16 330 struct remove_reference<T&>
Chris@16 331 {
Chris@16 332 typedef T type;
Chris@16 333 };
Chris@16 334
Chris@16 335 template<class Class>
Chris@16 336 class is_empty_class
Chris@16 337 {
Chris@16 338 template <typename T>
Chris@16 339 struct empty_helper_t1 : public T
Chris@16 340 {
Chris@16 341 empty_helper_t1();
Chris@16 342 int i[256];
Chris@16 343 };
Chris@16 344
Chris@16 345 struct empty_helper_t2
Chris@16 346 { int i[256]; };
Chris@16 347
Chris@16 348 public:
Chris@16 349 static const bool value = sizeof(empty_helper_t1<Class>) == sizeof(empty_helper_t2);
Chris@16 350 };
Chris@16 351
Chris@16 352 template<std::size_t S>
Chris@16 353 struct ls_zeros
Chris@16 354 {
Chris@16 355 static const std::size_t value = (S & std::size_t(1)) ? 0 : (1 + ls_zeros<(S>>1u)>::value);
Chris@16 356 };
Chris@16 357
Chris@16 358 template<>
Chris@16 359 struct ls_zeros<0>
Chris@16 360 {
Chris@16 361 static const std::size_t value = 0;
Chris@16 362 };
Chris@16 363
Chris@16 364 template<>
Chris@16 365 struct ls_zeros<1>
Chris@16 366 {
Chris@16 367 static const std::size_t value = 0;
Chris@16 368 };
Chris@16 369
Chris@16 370 } //namespace detail
Chris@16 371 } //namespace intrusive
Chris@16 372 } //namespace boost
Chris@16 373
Chris@16 374 #include <boost/intrusive/detail/config_end.hpp>
Chris@16 375
Chris@16 376 #endif //BOOST_INTRUSIVE_DETAIL_MPL_HPP