| 1 | ////////////////////////////////////////////////////////////////////////////// |
| 2 | // (C) Copyright John Maddock 2000. |
| 3 | // (C) Copyright Ion Gaztanaga 2005-2015. |
| 4 | // |
| 5 | // Distributed under the Boost Software License, Version 1.0. |
| 6 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 7 | // http://www.boost.org/LICENSE_1_0.txt) |
| 8 | // |
| 9 | // See http://www.boost.org/libs/move for documentation. |
| 10 | // |
| 11 | // The alignment and Type traits implementation comes from |
| 12 | // John Maddock's TypeTraits library. |
| 13 | // |
| 14 | // Some other tricks come from Howard Hinnant's papers and StackOverflow replies |
| 15 | ////////////////////////////////////////////////////////////////////////////// |
| 16 | #ifndef BOOST_MOVE_DETAIL_TYPE_TRAITS_HPP |
| 17 | #define BOOST_MOVE_DETAIL_TYPE_TRAITS_HPP |
| 18 | |
| 19 | #ifndef BOOST_CONFIG_HPP |
| 20 | # include <boost/config.hpp> |
| 21 | #endif |
| 22 | # |
| 23 | #if defined(BOOST_HAS_PRAGMA_ONCE) |
| 24 | # pragma once |
| 25 | #endif |
| 26 | |
| 27 | #include <boost/move/detail/config_begin.hpp> |
| 28 | #include <boost/move/detail/workaround.hpp> |
| 29 | |
| 30 | // move/detail |
| 31 | #include <boost/move/detail/meta_utils.hpp> |
| 32 | // other |
| 33 | #include <cassert> |
| 34 | // std |
| 35 | #include <cstddef> |
| 36 | |
| 37 | //Use of Boost.TypeTraits leads to long preprocessed source code due to |
| 38 | //MPL dependencies. We'll use intrinsics directly and make or own |
| 39 | //simplified version of TypeTraits. |
| 40 | //If someday Boost.TypeTraits dependencies are minimized, we should |
| 41 | //revisit this file redirecting code to Boost.TypeTraits traits. |
| 42 | |
| 43 | //These traits don't care about volatile, reference or other checks |
| 44 | //made by Boost.TypeTraits because no volatile or reference types |
| 45 | //can be hold in Boost.Containers. This helps to avoid any Boost.TypeTraits |
| 46 | //dependency. |
| 47 | |
| 48 | // Helper macros for builtin compiler support. |
| 49 | // If your compiler has builtin support for any of the following |
| 50 | // traits concepts, then redefine the appropriate macros to pick |
| 51 | // up on the compiler support: |
| 52 | // |
| 53 | // (these should largely ignore cv-qualifiers) |
| 54 | // BOOST_MOVE_IS_POD(T) should evaluate to true if T is a POD type |
| 55 | // BOOST_MOVE_HAS_TRIVIAL_CONSTRUCTOR(T) should evaluate to true if "T x;" has no effect |
| 56 | // BOOST_MOVE_HAS_TRIVIAL_COPY(T) should evaluate to true if T(t) <==> memcpy |
| 57 | // (Note: this trait does not guarantee T is copy constructible, the copy constructor could be deleted but still be trivial) |
| 58 | // BOOST_MOVE_HAS_TRIVIAL_MOVE_CONSTRUCTOR(T) should evaluate to true if T(boost::move(t)) <==> memcpy |
| 59 | // BOOST_MOVE_HAS_TRIVIAL_ASSIGN(T) should evaluate to true if t = u <==> memcpy |
| 60 | // (Note: this trait does not guarantee T is assignable , the copy assignmen could be deleted but still be trivial) |
| 61 | // BOOST_MOVE_HAS_TRIVIAL_MOVE_ASSIGN(T) should evaluate to true if t = boost::move(u) <==> memcpy |
| 62 | // BOOST_MOVE_HAS_TRIVIAL_DESTRUCTOR(T) should evaluate to true if ~T() has no effect |
| 63 | // BOOST_MOVE_HAS_NOTHROW_CONSTRUCTOR(T) should evaluate to true if "T x;" can not throw |
| 64 | // BOOST_MOVE_HAS_NOTHROW_COPY(T) should evaluate to true if T(t) can not throw |
| 65 | // BOOST_MOVE_HAS_NOTHROW_ASSIGN(T) should evaluate to true if t = u can not throw |
| 66 | // BOOST_MOVE_IS_ENUM(T) should evaluate to true it t is a union type. |
| 67 | // BOOST_MOVE_HAS_NOTHROW_MOVE_CONSTRUCTOR(T) should evaluate to true if T has a non-throwing move constructor. |
| 68 | // BOOST_MOVE_HAS_NOTHROW_MOVE_ASSIGN(T) should evaluate to true if T has a non-throwing move assignment operator. |
| 69 | // |
| 70 | // The following can also be defined: when detected our implementation is greatly simplified. |
| 71 | // |
| 72 | // BOOST_ALIGNMENT_OF(T) should evaluate to the alignment requirements of type T. |
| 73 | |
| 74 | #if defined(__MSL_CPP__) && (__MSL_CPP__ >= 0x8000) |
| 75 | // Metrowerks compiler is acquiring intrinsic type traits support |
| 76 | // post version 8. We hook into the published interface to pick up |
| 77 | // user defined specializations as well as compiler intrinsics as |
| 78 | // and when they become available: |
| 79 | # include <msl_utility> |
| 80 | # define BOOST_MOVE_IS_UNION(T) BOOST_STD_EXTENSION_NAMESPACE::is_union<T>::value |
| 81 | # define BOOST_MOVE_IS_POD(T) BOOST_STD_EXTENSION_NAMESPACE::is_POD<T>::value |
| 82 | # define BOOST_MOVE_HAS_TRIVIAL_CONSTRUCTOR(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_default_ctor<T>::value |
| 83 | # define BOOST_MOVE_HAS_TRIVIAL_COPY(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_copy_ctor<T>::value |
| 84 | # define BOOST_MOVE_HAS_TRIVIAL_ASSIGN(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_assignment<T>::value |
| 85 | # define BOOST_MOVE_HAS_TRIVIAL_DESTRUCTOR(T) BOOST_STD_EXTENSION_NAMESPACE::has_trivial_dtor<T>::value |
| 86 | #endif |
| 87 | |
| 88 | #if (defined(BOOST_MSVC) && defined(BOOST_MSVC_FULL_VER) && (BOOST_MSVC_FULL_VER >=140050215))\ |
| 89 | || (defined(BOOST_INTEL) && defined(_MSC_VER) && (_MSC_VER >= 1500)) |
| 90 | # define BOOST_MOVE_IS_UNION(T) __is_union(T) |
| 91 | # define BOOST_MOVE_IS_POD(T) (__is_pod(T) && __has_trivial_constructor(T)) |
| 92 | # define BOOST_MOVE_IS_EMPTY(T) __is_empty(T) |
| 93 | # define BOOST_MOVE_HAS_TRIVIAL_CONSTRUCTOR(T) __has_trivial_constructor(T) |
| 94 | # define BOOST_MOVE_HAS_TRIVIAL_COPY(T) (__has_trivial_copy(T)|| ::boost::move_detail::is_pod<T>::value) |
| 95 | # define BOOST_MOVE_HAS_TRIVIAL_ASSIGN(T) (__has_trivial_assign(T) || ::boost::move_detail::is_pod<T>::value) |
| 96 | # define BOOST_MOVE_HAS_TRIVIAL_DESTRUCTOR(T) (__has_trivial_destructor(T) || ::boost::move_detail::is_pod<T>::value) |
| 97 | # define BOOST_MOVE_HAS_NOTHROW_CONSTRUCTOR(T) (__has_nothrow_constructor(T) || ::boost::move_detail::is_trivially_default_constructible<T>::value) |
| 98 | # define BOOST_MOVE_HAS_NOTHROW_COPY(T) (__has_nothrow_copy(T) || ::boost::move_detail::is_trivially_copy_constructible<T>::value) |
| 99 | # define BOOST_MOVE_HAS_NOTHROW_ASSIGN(T) (__has_nothrow_assign(T) || ::boost::move_detail::is_trivially_copy_assignable<T>::value) |
| 100 | |
| 101 | # define BOOST_MOVE_IS_ENUM(T) __is_enum(T) |
| 102 | # if defined(_MSC_VER) && (_MSC_VER >= 1700) |
| 103 | # define BOOST_MOVE_HAS_TRIVIAL_MOVE_CONSTRUCTOR(T) (__has_trivial_move_constructor(T) || ::boost::move_detail::is_pod<T>::value) |
| 104 | # define BOOST_MOVE_HAS_TRIVIAL_MOVE_ASSIGN(T) (__has_trivial_move_assign(T) || ::boost::move_detail::is_pod<T>::value) |
| 105 | # endif |
| 106 | # if _MSC_FULL_VER >= 180020827 |
| 107 | # define BOOST_MOVE_HAS_NOTHROW_MOVE_ASSIGN(T) (__is_nothrow_assignable(T&, T&&)) |
| 108 | # define BOOST_MOVE_HAS_NOTHROW_MOVE_CONSTRUCTOR(T) (__is_nothrow_constructible(T, T&&)) |
| 109 | # endif |
| 110 | #endif |
| 111 | |
| 112 | #if defined(BOOST_CLANG) |
| 113 | // BOOST_MOVE_HAS_TRAIT |
| 114 | # if defined __is_identifier |
| 115 | # define BOOST_MOVE_HAS_TRAIT(T) (__has_extension(T) || !__is_identifier(__##T)) |
| 116 | # elif defined(__has_extension) |
| 117 | # define BOOST_MOVE_HAS_TRAIT(T) __has_extension(T) |
| 118 | # else |
| 119 | # define BOOST_MOVE_HAS_TRAIT(T) 0 |
| 120 | # endif |
| 121 | |
| 122 | // BOOST_MOVE_IS_UNION |
| 123 | # if BOOST_MOVE_HAS_TRAIT(is_union) |
| 124 | # define BOOST_MOVE_IS_UNION(T) __is_union(T) |
| 125 | # endif |
| 126 | |
| 127 | // BOOST_MOVE_IS_ENUM |
| 128 | # if BOOST_MOVE_HAS_TRAIT(is_enum) |
| 129 | # define BOOST_MOVE_IS_ENUM(T) __is_enum(T) |
| 130 | # endif |
| 131 | |
| 132 | // BOOST_MOVE_IS_POD |
| 133 | # if (!defined(__GLIBCXX__) || (__GLIBCXX__ >= 20080306 && __GLIBCXX__ != 20080519)) && BOOST_MOVE_HAS_TRAIT(is_pod) |
| 134 | # define BOOST_MOVE_IS_POD(T) __is_pod(T) |
| 135 | # endif |
| 136 | |
| 137 | // BOOST_MOVE_IS_EMPTY |
| 138 | # if (!defined(__GLIBCXX__) || (__GLIBCXX__ >= 20080306 && __GLIBCXX__ != 20080519)) && BOOST_MOVE_HAS_TRAIT(is_empty) |
| 139 | # define BOOST_MOVE_IS_EMPTY(T) __is_empty(T) |
| 140 | # endif |
| 141 | |
| 142 | // BOOST_MOVE_HAS_TRIVIAL_CONSTRUCTOR |
| 143 | # if BOOST_MOVE_HAS_TRAIT(is_constructible) && BOOST_MOVE_HAS_TRAIT(is_trivially_constructible) |
| 144 | # define BOOST_MOVE_HAS_TRIVIAL_CONSTRUCTOR(T) __is_trivially_constructible(T) |
| 145 | # elif BOOST_MOVE_HAS_TRAIT(has_trivial_constructor) |
| 146 | # define BOOST_MOVE_HAS_TRIVIAL_CONSTRUCTOR(T) __has_trivial_constructor(T) |
| 147 | # endif |
| 148 | |
| 149 | // BOOST_MOVE_HAS_TRIVIAL_COPY |
| 150 | # if BOOST_MOVE_HAS_TRAIT(is_constructible) && BOOST_MOVE_HAS_TRAIT(is_trivially_constructible) |
| 151 | # define BOOST_MOVE_HAS_TRIVIAL_COPY(T) (__is_constructible(T, const T &) && __is_trivially_constructible(T, const T &)) |
| 152 | # elif BOOST_MOVE_HAS_TRAIT(has_trivial_copy) |
| 153 | # define BOOST_MOVE_HAS_TRIVIAL_COPY(T) __has_trivial_copy(T) |
| 154 | # endif |
| 155 | |
| 156 | // BOOST_MOVE_HAS_TRIVIAL_ASSIGN |
| 157 | # if BOOST_MOVE_HAS_TRAIT(is_assignable) && BOOST_MOVE_HAS_TRAIT(is_trivially_assignable) |
| 158 | # define BOOST_MOVE_HAS_TRIVIAL_ASSIGN(T) (__is_assignable(T, const T &) && __is_trivially_assignable(T, const T &)) |
| 159 | # elif BOOST_MOVE_HAS_TRAIT(has_trivial_copy) |
| 160 | # define BOOST_MOVE_HAS_TRIVIAL_ASSIGN(T) __has_trivial_assign(T) |
| 161 | # endif |
| 162 | |
| 163 | // BOOST_MOVE_HAS_TRIVIAL_DESTRUCTOR |
| 164 | # if BOOST_MOVE_HAS_TRAIT(is_trivially_destructible) |
| 165 | # define BOOST_MOVE_HAS_TRIVIAL_DESTRUCTOR(T) __is_trivially_destructible(T) |
| 166 | # elif BOOST_MOVE_HAS_TRAIT(has_trivial_destructor) |
| 167 | # define BOOST_MOVE_HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) |
| 168 | # endif |
| 169 | |
| 170 | // BOOST_MOVE_HAS_NOTHROW_CONSTRUCTOR |
| 171 | # if BOOST_MOVE_HAS_TRAIT(is_nothrow_constructible) |
| 172 | # define BOOST_MOVE_HAS_NOTHROW_CONSTRUCTOR(T) __is_nothrow_constructible(T) |
| 173 | # elif BOOST_MOVE_HAS_TRAIT(has_nothrow_constructor) |
| 174 | # define BOOST_MOVE_HAS_NOTHROW_CONSTRUCTOR(T) __has_nothrow_constructor(T) |
| 175 | # endif |
| 176 | |
| 177 | // BOOST_MOVE_HAS_NOTHROW_COPY |
| 178 | # if BOOST_MOVE_HAS_TRAIT(is_constructible) && BOOST_MOVE_HAS_TRAIT(is_nothrow_constructible) |
| 179 | # define BOOST_MOVE_HAS_NOTHROW_COPY(T) (__is_constructible(T, const T &) && __is_nothrow_constructible(T, const T &)) |
| 180 | # elif BOOST_MOVE_HAS_TRAIT(has_nothrow_copy) |
| 181 | # define BOOST_MOVE_HAS_NOTHROW_COPY(T) (__has_nothrow_copy(T)) |
| 182 | # endif |
| 183 | |
| 184 | // BOOST_MOVE_HAS_NOTHROW_ASSIGN |
| 185 | # if BOOST_MOVE_HAS_TRAIT(is_assignable) && BOOST_MOVE_HAS_TRAIT(is_nothrow_assignable) |
| 186 | # define BOOST_MOVE_HAS_NOTHROW_ASSIGN(T) (__is_assignable(T, const T &) && __is_nothrow_assignable(T, const T &)) |
| 187 | # elif BOOST_MOVE_HAS_TRAIT(has_nothrow_assign) |
| 188 | # define BOOST_MOVE_HAS_NOTHROW_ASSIGN(T) (__has_nothrow_assign(T)) |
| 189 | # endif |
| 190 | |
| 191 | // BOOST_MOVE_HAS_TRIVIAL_MOVE_CONSTRUCTOR |
| 192 | # if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) |
| 193 | |
| 194 | # if BOOST_MOVE_HAS_TRAIT(is_constructible) && BOOST_MOVE_HAS_TRAIT(is_trivially_constructible) |
| 195 | # define BOOST_MOVE_HAS_TRIVIAL_MOVE_CONSTRUCTOR(T) (__is_constructible(T, T&&) && __is_trivially_constructible(T, T&&)) |
| 196 | # elif BOOST_MOVE_HAS_TRAIT(has_trivial_move_constructor) |
| 197 | # define BOOST_MOVE_HAS_TRIVIAL_MOVE_CONSTRUCTOR(T) __has_trivial_move_constructor(T) |
| 198 | # endif |
| 199 | |
| 200 | // BOOST_MOVE_HAS_TRIVIAL_MOVE_ASSIGN |
| 201 | # if BOOST_MOVE_HAS_TRAIT(is_assignable) && BOOST_MOVE_HAS_TRAIT(is_trivially_assignable) |
| 202 | # define BOOST_MOVE_HAS_TRIVIAL_MOVE_ASSIGN(T) (__is_assignable(T, T&&) && __is_trivially_assignable(T, T&&)) |
| 203 | # elif BOOST_MOVE_HAS_TRAIT(has_trivial_move_assign) |
| 204 | # define BOOST_MOVE_HAS_TRIVIAL_MOVE_ASSIGN(T) __has_trivial_move_assign(T) |
| 205 | # endif |
| 206 | |
| 207 | // BOOST_MOVE_HAS_NOTHROW_MOVE_CONSTRUCTOR |
| 208 | # if BOOST_MOVE_HAS_TRAIT(is_constructible) && BOOST_MOVE_HAS_TRAIT(is_nothrow_constructible) |
| 209 | # define BOOST_MOVE_HAS_NOTHROW_MOVE_CONSTRUCTOR(T) (__is_constructible(T, T&&) && __is_nothrow_constructible(T, T&&)) |
| 210 | # elif BOOST_MOVE_HAS_TRAIT(has_nothrow_move_constructor) |
| 211 | # define BOOST_MOVE_HAS_NOTHROW_MOVE_CONSTRUCTOR(T) __has_nothrow_move_constructor(T) |
| 212 | # endif |
| 213 | |
| 214 | // BOOST_MOVE_HAS_NOTHROW_MOVE_ASSIGN |
| 215 | # if BOOST_MOVE_HAS_TRAIT(is_assignable) && BOOST_MOVE_HAS_TRAIT(is_nothrow_assignable) |
| 216 | # define BOOST_MOVE_HAS_NOTHROW_MOVE_ASSIGN(T) (__is_assignable(T, T&&) && __is_nothrow_assignable(T, T&&)) |
| 217 | # elif BOOST_MOVE_HAS_TRAIT(has_nothrow_move_assign) |
| 218 | # define BOOST_MOVE_HAS_NOTHROW_MOVE_ASSIGN(T) __has_nothrow_move_assign(T) |
| 219 | # endif |
| 220 | |
| 221 | # endif //BOOST_NO_CXX11_RVALUE_REFERENCES |
| 222 | |
| 223 | // BOOST_MOVE_ALIGNMENT_OF |
| 224 | # define BOOST_MOVE_ALIGNMENT_OF(T) __alignof(T) |
| 225 | |
| 226 | #endif //#if defined(BOOST_CLANG) |
| 227 | |
| 228 | #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3) && !defined(__GCCXML__))) && !defined(BOOST_CLANG) |
| 229 | |
| 230 | #ifdef BOOST_INTEL |
| 231 | # define BOOST_MOVE_INTEL_TT_OPTS || ::boost::move_detail::is_pod<T>::value |
| 232 | #else |
| 233 | # define BOOST_MOVE_INTEL_TT_OPTS |
| 234 | #endif |
| 235 | |
| 236 | # define BOOST_MOVE_IS_UNION(T) __is_union(T) |
| 237 | # define BOOST_MOVE_IS_POD(T) __is_pod(T) |
| 238 | # define BOOST_MOVE_IS_EMPTY(T) __is_empty(T) |
| 239 | # define BOOST_MOVE_HAS_TRIVIAL_CONSTRUCTOR(T) ((__has_trivial_constructor(T) BOOST_MOVE_INTEL_TT_OPTS)) |
| 240 | |
| 241 | # if defined(BOOST_GCC) && (BOOST_GCC > 50000) |
| 242 | # define BOOST_MOVE_HAS_TRIVIAL_COPY(T) (__is_trivially_constructible(T, const T &)) |
| 243 | # define BOOST_MOVE_HAS_TRIVIAL_ASSIGN(T) (__is_trivially_assignable(T, const T &)) |
| 244 | # else |
| 245 | # define BOOST_MOVE_HAS_TRIVIAL_COPY(T) ((__has_trivial_copy(T) BOOST_MOVE_INTEL_TT_OPTS)) |
| 246 | # define BOOST_MOVE_HAS_TRIVIAL_ASSIGN(T) ((__has_trivial_assign(T) BOOST_MOVE_INTEL_TT_OPTS) ) |
| 247 | # endif |
| 248 | |
| 249 | # define BOOST_MOVE_HAS_TRIVIAL_DESTRUCTOR(T) (__has_trivial_destructor(T) BOOST_MOVE_INTEL_TT_OPTS) |
| 250 | # define BOOST_MOVE_HAS_NOTHROW_CONSTRUCTOR(T) (__has_nothrow_constructor(T) BOOST_MOVE_INTEL_TT_OPTS) |
| 251 | # define BOOST_MOVE_HAS_NOTHROW_COPY(T) ((__has_nothrow_copy(T) BOOST_MOVE_INTEL_TT_OPTS)) |
| 252 | # define BOOST_MOVE_HAS_NOTHROW_ASSIGN(T) ((__has_nothrow_assign(T) BOOST_MOVE_INTEL_TT_OPTS)) |
| 253 | |
| 254 | #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_SFINAE_EXPR) |
| 255 | |
| 256 | template <typename T> |
| 257 | T && boost_move_tt_declval() BOOST_NOEXCEPT; |
| 258 | |
| 259 | # if defined(BOOST_GCC) && (BOOST_GCC >= 80000) |
| 260 | // __is_assignable / __is_constructible implemented |
| 261 | # define BOOST_MOVE_IS_ASSIGNABLE(T, U) __is_assignable(T, U) |
| 262 | # define BOOST_MOVE_IS_CONSTRUCTIBLE(T, U) __is_constructible(T, U) |
| 263 | # else |
| 264 | |
| 265 | template<typename Tt, typename Ut> |
| 266 | class boost_move_tt_is_assignable |
| 267 | { |
| 268 | struct twochar { char dummy[2]; }; |
| 269 | template < class T |
| 270 | , class U |
| 271 | , class = decltype(boost_move_tt_declval<T>() = boost_move_tt_declval<U>()) |
| 272 | > static char test(int); |
| 273 | |
| 274 | template<class, class> static twochar test(...); |
| 275 | |
| 276 | public: |
| 277 | static const bool value = sizeof(test<Tt, Ut>(0)) == sizeof(char); |
| 278 | }; |
| 279 | |
| 280 | template<typename Tt, typename Ut> |
| 281 | class boost_move_tt_is_constructible |
| 282 | { |
| 283 | struct twochar { char dummy[2]; }; |
| 284 | template < class T |
| 285 | , class U |
| 286 | , class = decltype(T(boost_move_tt_declval<U>())) |
| 287 | > static char test(int); |
| 288 | |
| 289 | template<class, class> static twochar test(...); |
| 290 | |
| 291 | public: |
| 292 | static const bool value = sizeof(test<Tt, Ut>(0)) == sizeof(char); |
| 293 | }; |
| 294 | |
| 295 | # define BOOST_MOVE_IS_ASSIGNABLE(T, U) boost_move_tt_is_assignable<T,U>::value |
| 296 | # define BOOST_MOVE_IS_CONSTRUCTIBLE(T, U) boost_move_tt_is_constructible<T, U>::value |
| 297 | |
| 298 | # endif |
| 299 | |
| 300 | template <typename T, typename U, bool = BOOST_MOVE_IS_ASSIGNABLE(T, U)> |
| 301 | struct boost_move_tt_is_nothrow_assignable |
| 302 | { |
| 303 | static const bool value = false; |
| 304 | }; |
| 305 | |
| 306 | template <typename T, typename U> |
| 307 | struct boost_move_tt_is_nothrow_assignable<T, U, true> |
| 308 | { |
| 309 | #if !defined(BOOST_NO_CXX11_NOEXCEPT) |
| 310 | static const bool value = noexcept(boost_move_tt_declval<T>() = boost_move_tt_declval<U>()); |
| 311 | #else |
| 312 | static const bool value = false; |
| 313 | #endif |
| 314 | }; |
| 315 | |
| 316 | template <typename T, typename U, bool = BOOST_MOVE_IS_CONSTRUCTIBLE(T, U)> |
| 317 | struct boost_move_tt_is_nothrow_constructible |
| 318 | { |
| 319 | static const bool value = false; |
| 320 | }; |
| 321 | |
| 322 | template <typename T, typename U> |
| 323 | struct boost_move_tt_is_nothrow_constructible<T, U, true> |
| 324 | { |
| 325 | #if !defined(BOOST_NO_CXX11_NOEXCEPT) |
| 326 | static const bool value = noexcept(T(boost_move_tt_declval<U>())); |
| 327 | #else |
| 328 | static const bool value = false; |
| 329 | #endif |
| 330 | }; |
| 331 | |
| 332 | # define BOOST_MOVE_HAS_NOTHROW_MOVE_ASSIGN(T) boost_move_tt_is_nothrow_assignable<T, T&&>::value |
| 333 | # define BOOST_MOVE_HAS_NOTHROW_MOVE_CONSTRUCTOR(T) boost_move_tt_is_nothrow_constructible<T, T&&>::value |
| 334 | |
| 335 | # endif |
| 336 | |
| 337 | # define BOOST_MOVE_IS_ENUM(T) __is_enum(T) |
| 338 | |
| 339 | // BOOST_MOVE_ALIGNMENT_OF |
| 340 | # if (!defined(unix) && !defined(__unix__)) || defined(__LP64__) |
| 341 | // GCC sometimes lies about alignment requirements |
| 342 | // of type double on 32-bit unix platforms, use the |
| 343 | // old implementation instead in that case: |
| 344 | # define BOOST_MOVE_ALIGNMENT_OF(T) __alignof__(T) |
| 345 | # endif |
| 346 | #endif |
| 347 | |
| 348 | #if defined(__ghs__) && (__GHS_VERSION_NUMBER >= 600) |
| 349 | |
| 350 | # define BOOST_MOVE_IS_UNION(T) __is_union(T) |
| 351 | # define BOOST_MOVE_IS_POD(T) __is_pod(T) |
| 352 | # define BOOST_MOVE_IS_EMPTY(T) __is_empty(T) |
| 353 | # define BOOST_MOVE_HAS_TRIVIAL_CONSTRUCTOR(T) __has_trivial_constructor(T) |
| 354 | # define BOOST_MOVE_HAS_TRIVIAL_COPY(T) (__has_trivial_copy(T)) |
| 355 | # define BOOST_MOVE_HAS_TRIVIAL_ASSIGN(T) (__has_trivial_assign(T)) |
| 356 | # define BOOST_MOVE_HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) |
| 357 | # define BOOST_MOVE_HAS_NOTHROW_CONSTRUCTOR(T) __has_nothrow_constructor(T) |
| 358 | # define BOOST_MOVE_HAS_NOTHROW_COPY(T) (__has_nothrow_copy(T)) |
| 359 | # define BOOST_MOVE_HAS_NOTHROW_ASSIGN(T) (__has_nothrow_assign(T)) |
| 360 | |
| 361 | # define BOOST_MOVE_IS_ENUM(T) __is_enum(T) |
| 362 | # define BOOST_MOVE_ALIGNMENT_OF(T) __alignof__(T) |
| 363 | #endif |
| 364 | |
| 365 | # if defined(BOOST_CODEGEARC) |
| 366 | # define BOOST_MOVE_IS_UNION(T) __is_union(T) |
| 367 | # define BOOST_MOVE_IS_POD(T) __is_pod(T) |
| 368 | # define BOOST_MOVE_IS_EMPTY(T) __is_empty(T) |
| 369 | # define BOOST_MOVE_HAS_TRIVIAL_CONSTRUCTOR(T) (__has_trivial_default_constructor(T)) |
| 370 | # define BOOST_MOVE_HAS_TRIVIAL_COPY(T) (__has_trivial_copy_constructor(T)) |
| 371 | # define BOOST_MOVE_HAS_TRIVIAL_ASSIGN(T) (__has_trivial_assign(T)) |
| 372 | # define BOOST_MOVE_HAS_TRIVIAL_DESTRUCTOR(T) (__has_trivial_destructor(T)) |
| 373 | # define BOOST_MOVE_HAS_NOTHROW_CONSTRUCTOR(T) (__has_nothrow_default_constructor(T)) |
| 374 | # define BOOST_MOVE_HAS_NOTHROW_COPY(T) (__has_nothrow_copy_constructor(T)) |
| 375 | # define BOOST_MOVE_HAS_NOTHROW_ASSIGN(T) (__has_nothrow_assign(T)) |
| 376 | |
| 377 | # define BOOST_MOVE_IS_ENUM(T) __is_enum(T) |
| 378 | # define BOOST_MOVE_ALIGNMENT_OF(T) alignof(T) |
| 379 | |
| 380 | #endif |
| 381 | |
| 382 | //Fallback definitions |
| 383 | |
| 384 | #ifdef BOOST_MOVE_IS_UNION |
| 385 | #define BOOST_MOVE_IS_UNION_IMPL(T) BOOST_MOVE_IS_UNION(T) |
| 386 | #else |
| 387 | #define BOOST_MOVE_IS_UNION_IMPL(T) false |
| 388 | #endif |
| 389 | |
| 390 | #ifdef BOOST_MOVE_IS_POD |
| 391 | //in some compilers the intrinsic is limited to class types so add scalar and void |
| 392 | #define BOOST_MOVE_IS_POD_IMPL(T) (::boost::move_detail::is_scalar<T>::value ||\ |
| 393 | ::boost::move_detail::is_void<T>::value ||\ |
| 394 | BOOST_MOVE_IS_POD(T)) |
| 395 | #else |
| 396 | #define BOOST_MOVE_IS_POD_IMPL(T) \ |
| 397 | (::boost::move_detail::is_scalar<T>::value || ::boost::move_detail::is_void<T>::value) |
| 398 | #endif |
| 399 | |
| 400 | #ifdef BOOST_MOVE_IS_EMPTY |
| 401 | #define BOOST_MOVE_IS_EMPTY_IMPL(T) BOOST_MOVE_IS_EMPTY(T) |
| 402 | #else |
| 403 | #define BOOST_MOVE_IS_EMPTY_IMPL(T) ::boost::move_detail::is_empty_nonintrinsic<T>::value |
| 404 | #endif |
| 405 | |
| 406 | #ifdef BOOST_MOVE_HAS_TRIVIAL_COPY |
| 407 | #define BOOST_MOVE_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) ::boost::move_detail::is_pod<T>::value ||\ |
| 408 | (::boost::move_detail::is_copy_constructible<T>::value &&\ |
| 409 | BOOST_MOVE_HAS_TRIVIAL_COPY(T)) |
| 410 | #else |
| 411 | #define BOOST_MOVE_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) ::boost::move_detail::is_pod<T>::value |
| 412 | #endif |
| 413 | |
| 414 | #ifdef BOOST_MOVE_HAS_TRIVIAL_CONSTRUCTOR |
| 415 | #define BOOST_MOVE_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE(T) BOOST_MOVE_HAS_TRIVIAL_CONSTRUCTOR(T) || ::boost::move_detail::is_pod<T>::value |
| 416 | #else |
| 417 | #define BOOST_MOVE_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE(T) ::boost::move_detail::is_pod<T>::value |
| 418 | #endif |
| 419 | |
| 420 | #ifdef BOOST_MOVE_HAS_TRIVIAL_MOVE_CONSTRUCTOR |
| 421 | #define BOOST_MOVE_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE(T) BOOST_MOVE_HAS_TRIVIAL_MOVE_CONSTRUCTOR(T) || ::boost::move_detail::is_pod<T>::value |
| 422 | #else |
| 423 | #define BOOST_MOVE_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE(T) ::boost::move_detail::is_pod<T>::value |
| 424 | #endif |
| 425 | |
| 426 | #ifdef BOOST_MOVE_HAS_TRIVIAL_ASSIGN |
| 427 | #define BOOST_MOVE_IS_TRIVIALLY_COPY_ASSIGNABLE(T) ::boost::move_detail::is_pod<T>::value ||\ |
| 428 | ( ::boost::move_detail::is_copy_assignable<T>::value &&\ |
| 429 | BOOST_MOVE_HAS_TRIVIAL_ASSIGN(T)) |
| 430 | #else |
| 431 | #define BOOST_MOVE_IS_TRIVIALLY_COPY_ASSIGNABLE(T) ::boost::move_detail::is_pod<T>::value |
| 432 | #endif |
| 433 | |
| 434 | #ifdef BOOST_MOVE_HAS_TRIVIAL_MOVE_ASSIGN |
| 435 | #define BOOST_MOVE_IS_TRIVIALLY_MOVE_ASSIGNABLE(T) BOOST_MOVE_HAS_TRIVIAL_MOVE_ASSIGN(T) || ::boost::move_detail::is_pod<T>::value |
| 436 | #else |
| 437 | #define BOOST_MOVE_IS_TRIVIALLY_MOVE_ASSIGNABLE(T) ::boost::move_detail::is_pod<T>::value |
| 438 | #endif |
| 439 | |
| 440 | #ifdef BOOST_MOVE_HAS_TRIVIAL_DESTRUCTOR |
| 441 | #define BOOST_MOVE_IS_TRIVIALLY_DESTRUCTIBLE(T) BOOST_MOVE_HAS_TRIVIAL_DESTRUCTOR(T) || ::boost::move_detail::is_pod<T>::value |
| 442 | #else |
| 443 | #define BOOST_MOVE_IS_TRIVIALLY_DESTRUCTIBLE(T) ::boost::move_detail::is_pod<T>::value |
| 444 | #endif |
| 445 | |
| 446 | #ifdef BOOST_MOVE_HAS_NOTHROW_CONSTRUCTOR |
| 447 | #define BOOST_MOVE_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE(T) BOOST_MOVE_HAS_NOTHROW_CONSTRUCTOR(T) || ::boost::move_detail::is_pod<T>::value |
| 448 | #else |
| 449 | #define BOOST_MOVE_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE(T) ::boost::move_detail::is_pod<T>::value |
| 450 | #endif |
| 451 | |
| 452 | #ifdef BOOST_MOVE_HAS_NOTHROW_COPY |
| 453 | #define BOOST_MOVE_IS_NOTHROW_COPY_CONSTRUCTIBLE(T) BOOST_MOVE_HAS_NOTHROW_COPY(T) || ::boost::move_detail::is_pod<T>::value |
| 454 | #else |
| 455 | #define BOOST_MOVE_IS_NOTHROW_COPY_CONSTRUCTIBLE(T) BOOST_MOVE_IS_TRIVIALLY_COPY_ASSIGNABLE(T) |
| 456 | #endif |
| 457 | |
| 458 | #ifdef BOOST_MOVE_HAS_NOTHROW_ASSIGN |
| 459 | #define BOOST_MOVE_IS_NOTHROW_COPY_ASSIGNABLE(T) BOOST_MOVE_HAS_NOTHROW_ASSIGN(T) || ::boost::move_detail::is_pod<T>::value |
| 460 | #else |
| 461 | #define BOOST_MOVE_IS_NOTHROW_COPY_ASSIGNABLE(T) BOOST_MOVE_IS_TRIVIALLY_COPY_ASSIGNABLE(T) |
| 462 | #endif |
| 463 | |
| 464 | #ifdef BOOST_MOVE_HAS_NOTHROW_MOVE_CONSTRUCTOR |
| 465 | #define BOOST_MOVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE(T) BOOST_MOVE_HAS_NOTHROW_MOVE_CONSTRUCTOR(T) || ::boost::move_detail::is_pod<T>::value |
| 466 | #else |
| 467 | #define BOOST_MOVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE(T) BOOST_MOVE_IS_TRIVIALLY_MOVE_ASSIGNABLE(T) |
| 468 | #endif |
| 469 | |
| 470 | #ifdef BOOST_MOVE_HAS_NOTHROW_MOVE_ASSIGN |
| 471 | #define BOOST_MOVE_IS_NOTHROW_MOVE_ASSIGNABLE(T) BOOST_MOVE_HAS_NOTHROW_MOVE_ASSIGN(T) || ::boost::move_detail::is_pod<T>::value |
| 472 | #else |
| 473 | #define BOOST_MOVE_IS_NOTHROW_MOVE_ASSIGNABLE(T) BOOST_MOVE_IS_TRIVIALLY_MOVE_ASSIGNABLE(T) |
| 474 | #endif |
| 475 | |
| 476 | #ifdef BOOST_MOVE_IS_ENUM |
| 477 | #define BOOST_MOVE_IS_ENUM_IMPL(T) BOOST_MOVE_IS_ENUM(T) |
| 478 | #else |
| 479 | #define BOOST_MOVE_IS_ENUM_IMPL(T) ::boost::move_detail::is_enum_nonintrinsic<T>::value |
| 480 | #endif |
| 481 | |
| 482 | namespace boost { |
| 483 | namespace move_detail { |
| 484 | |
| 485 | ////////////////////////// |
| 486 | // is_reference |
| 487 | ////////////////////////// |
| 488 | template<class T> |
| 489 | struct is_reference |
| 490 | { static const bool value = false; }; |
| 491 | |
| 492 | template<class T> |
| 493 | struct is_reference<T&> |
| 494 | { static const bool value = true; }; |
| 495 | |
| 496 | #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) |
| 497 | template<class T> |
| 498 | struct is_reference<T&&> |
| 499 | { static const bool value = true; }; |
| 500 | #endif |
| 501 | |
| 502 | ////////////////////////// |
| 503 | // is_pointer |
| 504 | ////////////////////////// |
| 505 | template<class T> |
| 506 | struct is_pointer |
| 507 | { static const bool value = false; }; |
| 508 | |
| 509 | template<class T> |
| 510 | struct is_pointer<T*> |
| 511 | { static const bool value = true; }; |
| 512 | |
| 513 | ////////////////////////// |
| 514 | // is_const |
| 515 | ////////////////////////// |
| 516 | template<class T> |
| 517 | struct is_const |
| 518 | { static const bool value = false; }; |
| 519 | |
| 520 | template<class T> |
| 521 | struct is_const<const T> |
| 522 | { static const bool value = true; }; |
| 523 | |
| 524 | ////////////////////////// |
| 525 | // unvoid_ref |
| 526 | ////////////////////////// |
| 527 | template <typename T> struct unvoid_ref : add_lvalue_reference<T>{}; |
| 528 | template <> struct unvoid_ref<void> { typedef unvoid_ref & type; }; |
| 529 | template <> struct unvoid_ref<const void> { typedef unvoid_ref & type; }; |
| 530 | template <> struct unvoid_ref<volatile void> { typedef unvoid_ref & type; }; |
| 531 | template <> struct unvoid_ref<const volatile void> { typedef unvoid_ref & type; }; |
| 532 | |
| 533 | template <typename T> |
| 534 | struct add_reference : add_lvalue_reference<T> |
| 535 | {}; |
| 536 | |
| 537 | ////////////////////////// |
| 538 | // add_const_reference |
| 539 | ////////////////////////// |
| 540 | template <class T> |
| 541 | struct add_const_reference |
| 542 | { typedef const T &type; }; |
| 543 | |
| 544 | template <class T> |
| 545 | struct add_const_reference<T&> |
| 546 | { typedef T& type; }; |
| 547 | |
| 548 | ////////////////////////// |
| 549 | // add_const_if_c |
| 550 | ////////////////////////// |
| 551 | template<class T, bool Add> |
| 552 | struct add_const_if_c |
| 553 | : if_c<Add, typename add_const<T>::type, T> |
| 554 | {}; |
| 555 | |
| 556 | ////////////////////////// |
| 557 | // remove_const |
| 558 | ////////////////////////// |
| 559 | template<class T> |
| 560 | struct remove_const |
| 561 | { typedef T type; }; |
| 562 | |
| 563 | template<class T> |
| 564 | struct remove_const< const T> |
| 565 | { typedef T type; }; |
| 566 | |
| 567 | ////////////////////////// |
| 568 | // remove_cv |
| 569 | ////////////////////////// |
| 570 | template<typename T> struct remove_cv { typedef T type; }; |
| 571 | template<typename T> struct remove_cv<const T> { typedef T type; }; |
| 572 | template<typename T> struct remove_cv<const volatile T> { typedef T type; }; |
| 573 | template<typename T> struct remove_cv<volatile T> { typedef T type; }; |
| 574 | |
| 575 | ////////////////////////// |
| 576 | // remove_cvref |
| 577 | ////////////////////////// |
| 578 | template<class T> |
| 579 | struct remove_cvref |
| 580 | : remove_cv<typename remove_reference<T>::type> |
| 581 | { |
| 582 | }; |
| 583 | |
| 584 | ////////////////////////// |
| 585 | // make_unsigned |
| 586 | ////////////////////////// |
| 587 | template <class T> |
| 588 | struct make_unsigned_impl { typedef T type; }; |
| 589 | template <> struct make_unsigned_impl<signed char> { typedef unsigned char type; }; |
| 590 | template <> struct make_unsigned_impl<signed short> { typedef unsigned short type; }; |
| 591 | template <> struct make_unsigned_impl<signed int> { typedef unsigned int type; }; |
| 592 | template <> struct make_unsigned_impl<signed long> { typedef unsigned long type; }; |
| 593 | #ifdef BOOST_HAS_LONG_LONG |
| 594 | template <> struct make_unsigned_impl< ::boost::long_long_type > { typedef ::boost::ulong_long_type type; }; |
| 595 | #endif |
| 596 | |
| 597 | template <class T> |
| 598 | struct make_unsigned |
| 599 | : make_unsigned_impl<typename remove_cv<T>::type> |
| 600 | {}; |
| 601 | |
| 602 | ////////////////////////// |
| 603 | // is_floating_point |
| 604 | ////////////////////////// |
| 605 | template<class T> struct is_floating_point_cv { static const bool value = false; }; |
| 606 | template<> struct is_floating_point_cv<float> { static const bool value = true; }; |
| 607 | template<> struct is_floating_point_cv<double> { static const bool value = true; }; |
| 608 | template<> struct is_floating_point_cv<long double> { static const bool value = true; }; |
| 609 | |
| 610 | template<class T> |
| 611 | struct is_floating_point |
| 612 | : is_floating_point_cv<typename remove_cv<T>::type> |
| 613 | {}; |
| 614 | |
| 615 | ////////////////////////// |
| 616 | // is_integral |
| 617 | ////////////////////////// |
| 618 | template<class T> struct is_integral_cv { static const bool value = false; }; |
| 619 | template<> struct is_integral_cv< bool>{ static const bool value = true; }; |
| 620 | template<> struct is_integral_cv< char>{ static const bool value = true; }; |
| 621 | template<> struct is_integral_cv< unsigned char>{ static const bool value = true; }; |
| 622 | template<> struct is_integral_cv< signed char>{ static const bool value = true; }; |
| 623 | #ifndef BOOST_NO_CXX11_CHAR16_T |
| 624 | template<> struct is_integral_cv< char16_t>{ static const bool value = true; }; |
| 625 | #endif |
| 626 | #ifndef BOOST_NO_CXX11_CHAR32_T |
| 627 | template<> struct is_integral_cv< char32_t>{ static const bool value = true; }; |
| 628 | #endif |
| 629 | #ifndef BOOST_NO_INTRINSIC_WCHAR_T |
| 630 | template<> struct is_integral_cv< wchar_t>{ static const bool value = true; }; |
| 631 | #endif |
| 632 | template<> struct is_integral_cv< short>{ static const bool value = true; }; |
| 633 | template<> struct is_integral_cv< unsigned short>{ static const bool value = true; }; |
| 634 | template<> struct is_integral_cv< int>{ static const bool value = true; }; |
| 635 | template<> struct is_integral_cv< unsigned int>{ static const bool value = true; }; |
| 636 | template<> struct is_integral_cv< long>{ static const bool value = true; }; |
| 637 | template<> struct is_integral_cv< unsigned long>{ static const bool value = true; }; |
| 638 | #ifdef BOOST_HAS_LONG_LONG |
| 639 | template<> struct is_integral_cv< ::boost:: long_long_type>{ static const bool value = true; }; |
| 640 | template<> struct is_integral_cv< ::boost::ulong_long_type>{ static const bool value = true; }; |
| 641 | #endif |
| 642 | |
| 643 | template<class T> |
| 644 | struct is_integral |
| 645 | : public is_integral_cv<typename remove_cv<T>::type> |
| 646 | {}; |
| 647 | |
| 648 | ////////////////////////////////////// |
| 649 | // remove_all_extents |
| 650 | ////////////////////////////////////// |
| 651 | template <class T> |
| 652 | struct remove_all_extents |
| 653 | { typedef T type;}; |
| 654 | |
| 655 | template <class T> |
| 656 | struct remove_all_extents<T[]> |
| 657 | { typedef typename remove_all_extents<T>::type type; }; |
| 658 | |
| 659 | template <class T, std::size_t N> |
| 660 | struct remove_all_extents<T[N]> |
| 661 | { typedef typename remove_all_extents<T>::type type;}; |
| 662 | |
| 663 | ////////////////////////// |
| 664 | // is_scalar |
| 665 | ////////////////////////// |
| 666 | template<class T> |
| 667 | struct is_scalar |
| 668 | { static const bool value = is_integral<T>::value || is_floating_point<T>::value; }; |
| 669 | |
| 670 | ////////////////////////// |
| 671 | // is_void |
| 672 | ////////////////////////// |
| 673 | template<class T> |
| 674 | struct is_void_cv |
| 675 | { static const bool value = false; }; |
| 676 | |
| 677 | template<> |
| 678 | struct is_void_cv<void> |
| 679 | { static const bool value = true; }; |
| 680 | |
| 681 | template<class T> |
| 682 | struct is_void |
| 683 | : is_void_cv<typename remove_cv<T>::type> |
| 684 | {}; |
| 685 | |
| 686 | ////////////////////////////////////// |
| 687 | // is_array |
| 688 | ////////////////////////////////////// |
| 689 | template<class T> |
| 690 | struct is_array |
| 691 | { static const bool value = false; }; |
| 692 | |
| 693 | template<class T> |
| 694 | struct is_array<T[]> |
| 695 | { static const bool value = true; }; |
| 696 | |
| 697 | template<class T, std::size_t N> |
| 698 | struct is_array<T[N]> |
| 699 | { static const bool value = true; }; |
| 700 | |
| 701 | ////////////////////////////////////// |
| 702 | // is_member_pointer |
| 703 | ////////////////////////////////////// |
| 704 | template <class T> struct is_member_pointer_cv { static const bool value = false; }; |
| 705 | template <class T, class U>struct is_member_pointer_cv<T U::*> { static const bool value = true; }; |
| 706 | |
| 707 | template <class T> |
| 708 | struct is_member_pointer |
| 709 | : is_member_pointer_cv<typename remove_cv<T>::type> |
| 710 | {}; |
| 711 | |
| 712 | ////////////////////////////////////// |
| 713 | // is_nullptr_t |
| 714 | ////////////////////////////////////// |
| 715 | template <class T> |
| 716 | struct is_nullptr_t_cv |
| 717 | { static const bool value = false; }; |
| 718 | |
| 719 | #if !defined(BOOST_NO_CXX11_NULLPTR) |
| 720 | template <> |
| 721 | struct is_nullptr_t_cv |
| 722 | #if !defined(BOOST_NO_CXX11_DECLTYPE) |
| 723 | <decltype(nullptr)> |
| 724 | #else |
| 725 | <std::nullptr_t> |
| 726 | #endif |
| 727 | { static const bool value = true; }; |
| 728 | #endif |
| 729 | |
| 730 | template <class T> |
| 731 | struct is_nullptr_t |
| 732 | : is_nullptr_t_cv<typename remove_cv<T>::type> |
| 733 | {}; |
| 734 | |
| 735 | ////////////////////////////////////// |
| 736 | // is_function |
| 737 | ////////////////////////////////////// |
| 738 | //Inspired by libc++, thanks to Howard Hinnant |
| 739 | //For a function to pointer an lvalue of function type T can be implicitly converted to a prvalue |
| 740 | //pointer to that function. This does not apply to non-static member functions because lvalues |
| 741 | //that refer to non-static member functions do not exist. |
| 742 | template <class T> |
| 743 | struct is_reference_convertible_to_pointer |
| 744 | { |
| 745 | struct twochar { char dummy[2]; }; |
| 746 | template <class U> static char test(U*); |
| 747 | template <class U> static twochar test(...); |
| 748 | static T& source(); |
| 749 | static const bool value = sizeof(char) == sizeof(test<T>(source())); |
| 750 | }; |
| 751 | //Filter out: |
| 752 | // - class types that might have implicit conversions |
| 753 | // - void (to avoid forming a reference to void later) |
| 754 | // - references (e.g.: filtering reference to functions) |
| 755 | // - nullptr_t (convertible to pointer) |
| 756 | template < class T |
| 757 | , bool Filter = is_class_or_union<T>::value || |
| 758 | is_void<T>::value || |
| 759 | is_reference<T>::value || |
| 760 | is_nullptr_t<T>::value > |
| 761 | struct is_function_impl |
| 762 | { static const bool value = is_reference_convertible_to_pointer<T>::value; }; |
| 763 | |
| 764 | template <class T> |
| 765 | struct is_function_impl<T, true> |
| 766 | { static const bool value = false; }; |
| 767 | |
| 768 | template <class T> |
| 769 | struct is_function |
| 770 | : is_function_impl<T> |
| 771 | {}; |
| 772 | |
| 773 | ////////////////////////////////////// |
| 774 | // is_union |
| 775 | ////////////////////////////////////// |
| 776 | template<class T> |
| 777 | struct is_union_noextents_cv |
| 778 | { static const bool value = BOOST_MOVE_IS_UNION_IMPL(T); }; |
| 779 | |
| 780 | template<class T> |
| 781 | struct is_union |
| 782 | : is_union_noextents_cv<typename remove_cv<typename remove_all_extents<T>::type>::type> |
| 783 | {}; |
| 784 | |
| 785 | ////////////////////////////////////// |
| 786 | // is_class |
| 787 | ////////////////////////////////////// |
| 788 | template <class T> |
| 789 | struct is_class |
| 790 | { |
| 791 | static const bool value = is_class_or_union<T>::value && ! is_union<T>::value; |
| 792 | }; |
| 793 | |
| 794 | |
| 795 | ////////////////////////////////////// |
| 796 | // is_arithmetic |
| 797 | ////////////////////////////////////// |
| 798 | template <class T> |
| 799 | struct is_arithmetic |
| 800 | { |
| 801 | static const bool value = is_floating_point<T>::value || |
| 802 | is_integral<T>::value; |
| 803 | }; |
| 804 | |
| 805 | ////////////////////////////////////// |
| 806 | // is_member_function_pointer |
| 807 | ////////////////////////////////////// |
| 808 | template <class T> |
| 809 | struct is_member_function_pointer_cv |
| 810 | { |
| 811 | static const bool value = false; |
| 812 | }; |
| 813 | |
| 814 | template <class T, class C> |
| 815 | struct is_member_function_pointer_cv<T C::*> |
| 816 | : is_function<T> |
| 817 | {}; |
| 818 | |
| 819 | template <class T> |
| 820 | struct is_member_function_pointer |
| 821 | : is_member_function_pointer_cv<typename remove_cv<T>::type> |
| 822 | {}; |
| 823 | |
| 824 | ////////////////////////////////////// |
| 825 | // is_enum |
| 826 | ////////////////////////////////////// |
| 827 | #if !defined(BOOST_MOVE_IS_ENUM) |
| 828 | //Based on (http://howardhinnant.github.io/TypeHiearchy.pdf) |
| 829 | template <class T> |
| 830 | struct is_enum_nonintrinsic |
| 831 | { |
| 832 | static const bool value = !is_arithmetic<T>::value && |
| 833 | !is_reference<T>::value && |
| 834 | !is_class_or_union<T>::value && |
| 835 | !is_array<T>::value && |
| 836 | !is_void<T>::value && |
| 837 | !is_nullptr_t<T>::value && |
| 838 | !is_member_pointer<T>::value && |
| 839 | !is_pointer<T>::value && |
| 840 | !is_function<T>::value; |
| 841 | }; |
| 842 | #endif |
| 843 | |
| 844 | template <class T> |
| 845 | struct is_enum |
| 846 | { static const bool value = BOOST_MOVE_IS_ENUM_IMPL(T); }; |
| 847 | |
| 848 | ////////////////////////////////////// |
| 849 | // is_pod |
| 850 | ////////////////////////////////////// |
| 851 | template<class T> |
| 852 | struct is_pod_noextents_cv //for non-c++11 compilers, a safe fallback |
| 853 | { static const bool value = BOOST_MOVE_IS_POD_IMPL(T); }; |
| 854 | |
| 855 | template<class T> |
| 856 | struct is_pod |
| 857 | : is_pod_noextents_cv<typename remove_cv<typename remove_all_extents<T>::type>::type> |
| 858 | {}; |
| 859 | |
| 860 | ////////////////////////////////////// |
| 861 | // is_empty |
| 862 | ////////////////////////////////////// |
| 863 | #if !defined(BOOST_MOVE_IS_EMPTY) |
| 864 | |
| 865 | template <typename T> |
| 866 | struct empty_helper_t1 : public T |
| 867 | { |
| 868 | empty_helper_t1(); // hh compiler bug workaround |
| 869 | int i[256]; |
| 870 | private: |
| 871 | |
| 872 | empty_helper_t1(const empty_helper_t1&); |
| 873 | empty_helper_t1& operator=(const empty_helper_t1&); |
| 874 | }; |
| 875 | |
| 876 | struct empty_helper_t2 { int i[256]; }; |
| 877 | |
| 878 | template <typename T, bool IsClass = is_class<T>::value > |
| 879 | struct is_empty_nonintrinsic |
| 880 | { |
| 881 | static const bool value = false; |
| 882 | }; |
| 883 | |
| 884 | template <typename T> |
| 885 | struct is_empty_nonintrinsic<T, true> |
| 886 | { |
| 887 | static const bool value = sizeof(empty_helper_t1<T>) == sizeof(empty_helper_t2); |
| 888 | }; |
| 889 | #endif |
| 890 | |
| 891 | template <class T> |
| 892 | struct is_empty |
| 893 | { static const bool value = BOOST_MOVE_IS_EMPTY_IMPL(T); }; |
| 894 | |
| 895 | |
| 896 | template<class T> |
| 897 | struct has_boost_move_no_copy_constructor_or_assign_type |
| 898 | { |
| 899 | template <class U> |
| 900 | static yes_type test(typename U::boost_move_no_copy_constructor_or_assign*); |
| 901 | |
| 902 | template <class U> |
| 903 | static no_type test(...); |
| 904 | |
| 905 | static const bool value = sizeof(test<T>(0)) == sizeof(yes_type); |
| 906 | }; |
| 907 | |
| 908 | ////////////////////////////////////// |
| 909 | // is_copy_constructible |
| 910 | ////////////////////////////////////// |
| 911 | #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) && !defined(BOOST_NO_CXX11_DECLTYPE) \ |
| 912 | && !defined(BOOST_INTEL_CXX_VERSION) && \ |
| 913 | !(defined(BOOST_MSVC) && _MSC_VER == 1800) |
| 914 | #define BOOST_MOVE_TT_CXX11_IS_COPY_CONSTRUCTIBLE |
| 915 | #endif |
| 916 | |
| 917 | template<class T> |
| 918 | struct is_copy_constructible |
| 919 | { |
| 920 | // Intel compiler has problems with SFINAE for copy constructors and deleted functions: |
| 921 | // |
| 922 | // error: function *function_name* cannot be referenced -- it is a deleted function |
| 923 | // static yes_type test(U&, decltype(U(boost::declval<U&>()))* = 0); |
| 924 | // ^ |
| 925 | // MSVC 12.0 (Visual 2013) has problems when the copy constructor has been deleted. See: |
| 926 | // https://connect.microsoft.com/VisualStudio/feedback/details/800328/std-is-copy-constructible-is-broken |
| 927 | #if defined(BOOST_MOVE_TT_CXX11_IS_COPY_CONSTRUCTIBLE) |
| 928 | template<class U> static typename add_reference<U>::type source(); |
| 929 | static no_type test(...); |
| 930 | #ifdef BOOST_NO_CXX11_DECLTYPE |
| 931 | template <class U> |
| 932 | static yes_type test(U&, bool_<sizeof(U(source<U>()))>* = 0); |
| 933 | #else |
| 934 | template <class U> |
| 935 | static yes_type test(U&, decltype(U(source<U>()))* = 0); |
| 936 | #endif |
| 937 | static const bool value = sizeof(test(source<T>())) == sizeof(yes_type); |
| 938 | #else |
| 939 | static const bool value = !has_boost_move_no_copy_constructor_or_assign_type<T>::value; |
| 940 | #endif |
| 941 | }; |
| 942 | |
| 943 | |
| 944 | ////////////////////////////////////// |
| 945 | // is_copy_assignable |
| 946 | ////////////////////////////////////// |
| 947 | #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS) && !defined(BOOST_NO_CXX11_DECLTYPE) \ |
| 948 | && !defined(BOOST_INTEL_CXX_VERSION) && \ |
| 949 | !(defined(BOOST_MSVC) && _MSC_VER == 1800) |
| 950 | #define BOOST_MOVE_TT_CXX11_IS_COPY_ASSIGNABLE |
| 951 | #endif |
| 952 | |
| 953 | template <class T> |
| 954 | struct is_copy_assignable |
| 955 | { |
| 956 | // Intel compiler has problems with SFINAE for copy constructors and deleted functions: |
| 957 | // |
| 958 | // error: function *function_name* cannot be referenced -- it is a deleted function |
| 959 | // static boost::type_traits::yes_type test(T1&, decltype(T1(boost::declval<T1&>()))* = 0); |
| 960 | // ^ |
| 961 | // |
| 962 | // MSVC 12.0 (Visual 2013) has problems when the copy constructor has been deleted. See: |
| 963 | // https://connect.microsoft.com/VisualStudio/feedback/details/800328/std-is-copy-constructible-is-broken |
| 964 | #if defined(BOOST_MOVE_TT_CXX11_IS_COPY_ASSIGNABLE) |
| 965 | typedef char yes_type; |
| 966 | struct no_type { char dummy[2]; }; |
| 967 | |
| 968 | template <class U> static typename add_reference<U>::type source(); |
| 969 | template <class U> static decltype(source<U&>() = source<const U&>(), yes_type() ) test(int); |
| 970 | template <class> static no_type test(...); |
| 971 | |
| 972 | static const bool value = sizeof(test<T>(0)) == sizeof(yes_type); |
| 973 | #else |
| 974 | static const bool value = !has_boost_move_no_copy_constructor_or_assign_type<T>::value; |
| 975 | #endif |
| 976 | }; |
| 977 | |
| 978 | ////////////////////////////////////// |
| 979 | // is_trivially_destructible |
| 980 | ////////////////////////////////////// |
| 981 | template<class T> |
| 982 | struct is_trivially_destructible |
| 983 | { static const bool value = BOOST_MOVE_IS_TRIVIALLY_DESTRUCTIBLE(T); }; |
| 984 | |
| 985 | ////////////////////////////////////// |
| 986 | // is_trivially_default_constructible |
| 987 | ////////////////////////////////////// |
| 988 | template<class T> |
| 989 | struct is_trivially_default_constructible |
| 990 | { static const bool value = BOOST_MOVE_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE(T); }; |
| 991 | |
| 992 | ////////////////////////////////////// |
| 993 | // is_trivially_copy_constructible |
| 994 | ////////////////////////////////////// |
| 995 | template<class T> |
| 996 | struct is_trivially_copy_constructible |
| 997 | { |
| 998 | static const bool value = BOOST_MOVE_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T); |
| 999 | }; |
| 1000 | |
| 1001 | ////////////////////////////////////// |
| 1002 | // is_trivially_move_constructible |
| 1003 | ////////////////////////////////////// |
| 1004 | template<class T> |
| 1005 | struct is_trivially_move_constructible |
| 1006 | { static const bool value = BOOST_MOVE_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE(T); }; |
| 1007 | |
| 1008 | ////////////////////////////////////// |
| 1009 | // is_trivially_copy_assignable |
| 1010 | ////////////////////////////////////// |
| 1011 | template<class T> |
| 1012 | struct is_trivially_copy_assignable |
| 1013 | { |
| 1014 | static const bool value = BOOST_MOVE_IS_TRIVIALLY_COPY_ASSIGNABLE(T); |
| 1015 | }; |
| 1016 | |
| 1017 | ////////////////////////////////////// |
| 1018 | // is_trivially_move_assignable |
| 1019 | ////////////////////////////////////// |
| 1020 | template<class T> |
| 1021 | struct is_trivially_move_assignable |
| 1022 | { static const bool value = BOOST_MOVE_IS_TRIVIALLY_MOVE_ASSIGNABLE(T); }; |
| 1023 | |
| 1024 | ////////////////////////////////////// |
| 1025 | // is_nothrow_default_constructible |
| 1026 | ////////////////////////////////////// |
| 1027 | template<class T> |
| 1028 | struct is_nothrow_default_constructible |
| 1029 | { static const bool value = BOOST_MOVE_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE(T); }; |
| 1030 | |
| 1031 | ////////////////////////////////////// |
| 1032 | // is_nothrow_copy_constructible |
| 1033 | ////////////////////////////////////// |
| 1034 | template<class T> |
| 1035 | struct is_nothrow_copy_constructible |
| 1036 | { static const bool value = BOOST_MOVE_IS_NOTHROW_COPY_CONSTRUCTIBLE(T); }; |
| 1037 | |
| 1038 | ////////////////////////////////////// |
| 1039 | // is_nothrow_move_constructible |
| 1040 | ////////////////////////////////////// |
| 1041 | template<class T> |
| 1042 | struct is_nothrow_move_constructible |
| 1043 | { static const bool value = BOOST_MOVE_IS_NOTHROW_MOVE_CONSTRUCTIBLE(T); }; |
| 1044 | |
| 1045 | ////////////////////////////////////// |
| 1046 | // is_nothrow_copy_assignable |
| 1047 | ////////////////////////////////////// |
| 1048 | template<class T> |
| 1049 | struct is_nothrow_copy_assignable |
| 1050 | { static const bool value = BOOST_MOVE_IS_NOTHROW_COPY_ASSIGNABLE(T); }; |
| 1051 | |
| 1052 | ////////////////////////////////////// |
| 1053 | // is_nothrow_move_assignable |
| 1054 | ////////////////////////////////////// |
| 1055 | template<class T> |
| 1056 | struct is_nothrow_move_assignable |
| 1057 | { static const bool value = BOOST_MOVE_IS_NOTHROW_MOVE_ASSIGNABLE(T); }; |
| 1058 | |
| 1059 | ////////////////////////////////////// |
| 1060 | // is_nothrow_swappable |
| 1061 | ////////////////////////////////////// |
| 1062 | template<class T> |
| 1063 | struct is_nothrow_swappable |
| 1064 | { |
| 1065 | static const bool value = is_empty<T>::value || is_pod<T>::value; |
| 1066 | }; |
| 1067 | |
| 1068 | ////////////////////////////////////// |
| 1069 | // alignment_of |
| 1070 | ////////////////////////////////////// |
| 1071 | template <typename T> |
| 1072 | struct alignment_of_hack |
| 1073 | { |
| 1074 | T t1; |
| 1075 | char c; |
| 1076 | T t2; |
| 1077 | alignment_of_hack(); |
| 1078 | ~alignment_of_hack(); |
| 1079 | }; |
| 1080 | |
| 1081 | template <unsigned A, unsigned S> |
| 1082 | struct alignment_logic |
| 1083 | { static const std::size_t value = A < S ? A : S; }; |
| 1084 | |
| 1085 | template< typename T > |
| 1086 | struct alignment_of_impl |
| 1087 | #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1400) |
| 1088 | // With MSVC both the native __alignof operator |
| 1089 | // and our own logic gets things wrong from time to time :-( |
| 1090 | // Using a combination of the two seems to make the most of a bad job: |
| 1091 | : alignment_logic< sizeof(alignment_of_hack<T>) - 2*sizeof(T), __alignof(T)> |
| 1092 | {}; |
| 1093 | #elif !defined(BOOST_MOVE_ALIGNMENT_OF) |
| 1094 | : alignment_logic< sizeof(alignment_of_hack<T>) - 2*sizeof(T), sizeof(T)> |
| 1095 | {}; |
| 1096 | #else |
| 1097 | { static const std::size_t value = BOOST_MOVE_ALIGNMENT_OF(T); }; |
| 1098 | #endif |
| 1099 | |
| 1100 | template< typename T > |
| 1101 | struct alignment_of |
| 1102 | : alignment_of_impl<T> |
| 1103 | {}; |
| 1104 | |
| 1105 | class alignment_dummy; |
| 1106 | typedef void (*function_ptr)(); |
| 1107 | typedef int (alignment_dummy::*member_ptr); |
| 1108 | |
| 1109 | struct alignment_struct |
| 1110 | { long double dummy[4]; }; |
| 1111 | |
| 1112 | ///////////////////////////// |
| 1113 | // max_align_t |
| 1114 | ///////////////////////////// |
| 1115 | //This is not standard, but should work with all compilers |
| 1116 | union max_align |
| 1117 | { |
| 1118 | char char_; |
| 1119 | short short_; |
| 1120 | int int_; |
| 1121 | long long_; |
| 1122 | #ifdef BOOST_HAS_LONG_LONG |
| 1123 | ::boost::long_long_type long_long_; |
| 1124 | #endif |
| 1125 | float float_; |
| 1126 | double double_; |
| 1127 | void * void_ptr_; |
| 1128 | long double long_double_[4]; |
| 1129 | alignment_dummy *unknown_class_ptr_; |
| 1130 | function_ptr function_ptr_; |
| 1131 | alignment_struct alignment_struct_; |
| 1132 | }; |
| 1133 | |
| 1134 | typedef union max_align max_align_t; |
| 1135 | |
| 1136 | ///////////////////////////// |
| 1137 | // aligned_storage |
| 1138 | ///////////////////////////// |
| 1139 | |
| 1140 | #if defined(_MSC_VER) && defined(_M_IX86) |
| 1141 | |
| 1142 | // Special version for usual alignments on x86 MSVC because it might crash |
| 1143 | // when passsing aligned types by value even for 8 byte alignment. |
| 1144 | template<std::size_t Align> |
| 1145 | struct aligned_struct; |
| 1146 | |
| 1147 | template <> struct aligned_struct<1> { char data; }; |
| 1148 | template <> struct aligned_struct<2> { short data; }; |
| 1149 | template <> struct aligned_struct<4> { int data; }; |
| 1150 | template <> struct aligned_struct<8> { double data; }; |
| 1151 | |
| 1152 | #define BOOST_MOVE_ALIGNED_STRUCT(x) \ |
| 1153 | template <> struct aligned_struct<x> { \ |
| 1154 | __declspec(align(x)) char data; \ |
| 1155 | } |
| 1156 | BOOST_MOVE_ALIGNED_STRUCT(16); |
| 1157 | BOOST_MOVE_ALIGNED_STRUCT(32); |
| 1158 | BOOST_MOVE_ALIGNED_STRUCT(64); |
| 1159 | BOOST_MOVE_ALIGNED_STRUCT(128); |
| 1160 | BOOST_MOVE_ALIGNED_STRUCT(512); |
| 1161 | BOOST_MOVE_ALIGNED_STRUCT(1024); |
| 1162 | BOOST_MOVE_ALIGNED_STRUCT(2048); |
| 1163 | BOOST_MOVE_ALIGNED_STRUCT(4096); |
| 1164 | |
| 1165 | template<std::size_t Len, std::size_t Align> |
| 1166 | union aligned_union |
| 1167 | { |
| 1168 | typedef aligned_struct<Align> aligner_t; |
| 1169 | aligner_t aligner; |
| 1170 | unsigned char data[Len > sizeof(aligner_t) ? Len : sizeof(aligner_t)]; |
| 1171 | }; |
| 1172 | |
| 1173 | template<std::size_t Len, std::size_t Align> |
| 1174 | struct aligned_storage_impl |
| 1175 | { |
| 1176 | typedef aligned_union<Len, Align> type; |
| 1177 | }; |
| 1178 | |
| 1179 | #elif !defined(BOOST_NO_ALIGNMENT) |
| 1180 | |
| 1181 | template<std::size_t Len, std::size_t Align> |
| 1182 | struct aligned_struct; |
| 1183 | |
| 1184 | #define BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(A)\ |
| 1185 | template<std::size_t Len>\ |
| 1186 | struct BOOST_ALIGNMENT(A) aligned_struct<Len, A>\ |
| 1187 | {\ |
| 1188 | unsigned char data[Len];\ |
| 1189 | };\ |
| 1190 | // |
| 1191 | |
| 1192 | //Up to 4K alignment (typical page size) |
| 1193 | BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(0x1) |
| 1194 | BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(0x2) |
| 1195 | BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(0x4) |
| 1196 | BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(0x8) |
| 1197 | BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(0x10) |
| 1198 | BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(0x20) |
| 1199 | BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(0x40) |
| 1200 | BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(0x80) |
| 1201 | BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(0x100) |
| 1202 | BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(0x200) |
| 1203 | BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(0x400) |
| 1204 | BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(0x800) |
| 1205 | BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT(0x1000) |
| 1206 | |
| 1207 | #undef BOOST_MOVE_ALIGNED_STORAGE_WITH_BOOST_ALIGNMENT |
| 1208 | |
| 1209 | // Workaround for bogus [-Wignored-attributes] warning on GCC 6.x/7.x: don't use a type that "directly" carries the alignment attribute. |
| 1210 | // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82270 |
| 1211 | template<std::size_t Len, std::size_t Align> |
| 1212 | union aligned_struct_wrapper |
| 1213 | { |
| 1214 | typedef aligned_struct<Len, Align> aligner_t; |
| 1215 | aligned_struct<Len, Align> aligner; |
| 1216 | unsigned char data[Len > sizeof(aligner_t) ? Len : sizeof(aligner_t)]; |
| 1217 | }; |
| 1218 | |
| 1219 | template<std::size_t Len, std::size_t Align> |
| 1220 | struct aligned_storage_impl |
| 1221 | { |
| 1222 | typedef aligned_struct_wrapper<Len, Align> type; |
| 1223 | }; |
| 1224 | |
| 1225 | #else //BOOST_NO_ALIGNMENT |
| 1226 | |
| 1227 | template<class T, std::size_t Len> |
| 1228 | union aligned_union |
| 1229 | { |
| 1230 | T aligner; |
| 1231 | unsigned char data[Len > sizeof(T) ? Len : sizeof(T)]; |
| 1232 | }; |
| 1233 | |
| 1234 | template<std::size_t Len, std::size_t Align, class T, bool Ok> |
| 1235 | struct aligned_next; |
| 1236 | |
| 1237 | template<std::size_t Len, std::size_t Align, class T> |
| 1238 | struct aligned_next<Len, Align, T, true> |
| 1239 | { |
| 1240 | BOOST_MOVE_STATIC_ASSERT((alignment_of<T>::value == Align)); |
| 1241 | typedef aligned_union<T, Len> type; |
| 1242 | }; |
| 1243 | |
| 1244 | //End of search defaults to max_align_t |
| 1245 | template<std::size_t Len, std::size_t Align> |
| 1246 | struct aligned_next<Len, Align, max_align_t, false> |
| 1247 | { typedef aligned_union<max_align_t, Len> type; }; |
| 1248 | |
| 1249 | //Now define a search list through types |
| 1250 | #define BOOST_MOVE_ALIGNED_NEXT_STEP(TYPE, NEXT_TYPE)\ |
| 1251 | template<std::size_t Len, std::size_t Align>\ |
| 1252 | struct aligned_next<Len, Align, TYPE, false>\ |
| 1253 | : aligned_next<Len, Align, NEXT_TYPE, Align == alignment_of<NEXT_TYPE>::value>\ |
| 1254 | {};\ |
| 1255 | // |
| 1256 | BOOST_MOVE_ALIGNED_NEXT_STEP(long double, max_align_t) |
| 1257 | BOOST_MOVE_ALIGNED_NEXT_STEP(double, long double) |
| 1258 | #ifdef BOOST_HAS_LONG_LONG |
| 1259 | BOOST_MOVE_ALIGNED_NEXT_STEP(::boost::long_long_type, double) |
| 1260 | BOOST_MOVE_ALIGNED_NEXT_STEP(long, ::boost::long_long_type) |
| 1261 | #else |
| 1262 | BOOST_MOVE_ALIGNED_NEXT_STEP(long, double) |
| 1263 | #endif |
| 1264 | BOOST_MOVE_ALIGNED_NEXT_STEP(int, long) |
| 1265 | BOOST_MOVE_ALIGNED_NEXT_STEP(short, int) |
| 1266 | BOOST_MOVE_ALIGNED_NEXT_STEP(char, short) |
| 1267 | #undef BOOST_MOVE_ALIGNED_NEXT_STEP |
| 1268 | |
| 1269 | template<std::size_t Len, std::size_t Align> |
| 1270 | struct aligned_storage_impl |
| 1271 | : aligned_next<Len, Align, char, Align == alignment_of<char>::value> |
| 1272 | {}; |
| 1273 | |
| 1274 | #endif |
| 1275 | |
| 1276 | template<std::size_t Len, std::size_t Align = alignment_of<max_align_t>::value> |
| 1277 | struct aligned_storage |
| 1278 | { |
| 1279 | //Sanity checks for input parameters |
| 1280 | BOOST_MOVE_STATIC_ASSERT(Align > 0); |
| 1281 | |
| 1282 | //Sanity checks for output type |
| 1283 | typedef typename aligned_storage_impl<Len ? Len : 1, Align>::type type; |
| 1284 | static const std::size_t value = alignment_of<type>::value; |
| 1285 | BOOST_MOVE_STATIC_ASSERT(value >= Align); |
| 1286 | BOOST_MOVE_STATIC_ASSERT((value % Align) == 0); |
| 1287 | |
| 1288 | //Just in case someone instantiates aligned_storage |
| 1289 | //instead of aligned_storage::type (typical error). |
| 1290 | private: |
| 1291 | aligned_storage(); |
| 1292 | }; |
| 1293 | |
| 1294 | } //namespace move_detail { |
| 1295 | } //namespace boost { |
| 1296 | |
| 1297 | #include <boost/move/detail/config_end.hpp> |
| 1298 | |
| 1299 | #endif //#ifndef BOOST_MOVE_DETAIL_TYPE_TRAITS_HPP |
| 1300 | |