]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/optional/detail/experimental_traits.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / optional / detail / experimental_traits.hpp
1 // Copyright (C) 2017 Andrzej Krzemienski.
2 //
3 // Use, modification, and distribution is subject to the Boost Software
4 // License, 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/optional for documentation.
8 //
9 // You are welcome to contact the author at:
10 // akrzemi1@gmail.com
11
12 #ifndef BOOST_OPTIONAL_DETAIL_EXPERIMENTAL_TRAITS_04NOV2017_HPP
13 #define BOOST_OPTIONAL_DETAIL_EXPERIMENTAL_TRAITS_04NOV2017_HPP
14
15 #include <boost/config.hpp>
16 #include <boost/detail/workaround.hpp>
17 #include <boost/type_traits.hpp>
18
19 namespace boost { namespace optional_detail {
20
21 // The condition to use POD implementation
22
23 #ifdef BOOST_OPTIONAL_CONFIG_NO_POD_SPEC
24 # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
25 #elif defined BOOST_OPTIONAL_CONFIG_NO_SPEC_FOR_TRIVIAL_TYPES
26 # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
27 #elif !defined BOOST_HAS_TRIVIAL_CONSTRUCTOR
28 # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
29 #elif !defined BOOST_HAS_TRIVIAL_MOVE_ASSIGN
30 # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
31 #elif !defined BOOST_HAS_TRIVIAL_MOVE_CONSTRUCTOR
32 # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
33 #elif !defined BOOST_HAS_TRIVIAL_COPY
34 # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
35 #elif !defined BOOST_HAS_TRIVIAL_ASSIGN
36 # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
37 #elif !defined BOOST_HAS_TRIVIAL_DESTRUCTOR
38 # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
39 #elif BOOST_WORKAROUND(BOOST_GCC, < 50000)
40 # define BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
41 #endif
42
43 #if __cplusplus >= 201103L
44 # if BOOST_WORKAROUND(BOOST_GCC, >= 50000)
45 # define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
46 # elif (defined BOOST_CLANG)
47 # define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
48 # endif
49 #endif
50
51
52 #ifndef BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
53 # define BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T) BOOST_HAS_TRIVIAL_CONSTRUCTOR(T)
54 #else
55 # define BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T) std::is_trivially_default_constructible<T>::value
56 #endif
57
58
59
60 #ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
61 template <typename T>
62 struct is_type_trivially_copyable
63 : boost::conditional<(boost::has_trivial_copy_constructor<T>::value &&
64 boost::has_trivial_move_constructor<T>::value &&
65 boost::has_trivial_destructor<T>::value &&
66 boost::has_trivial_move_assign<T>::value &&
67 boost::has_trivial_assign<T>::value),
68 boost::true_type, boost::false_type>::type
69 {};
70 #else
71 template <typename T>
72 struct is_type_trivially_copyable
73 : boost::conditional<(boost::is_scalar<T>::value && !boost::is_const<T>::value && !boost::is_volatile<T>::value),
74 boost::true_type, boost::false_type>::type
75 {};
76 #endif
77
78
79
80 #ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
81 template <typename T>
82 struct optional_uses_direct_storage_for_
83 : boost::conditional< (is_type_trivially_copyable<T>::value && BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T)) ||
84 (boost::is_scalar<T>::value && !boost::is_const<T>::value && !boost::is_volatile<T>::value)
85 , boost::true_type, boost::false_type>::type
86 {};
87 #else
88 template <typename T>
89 struct optional_uses_direct_storage_for_
90 : boost::conditional<(boost::is_scalar<T>::value && !boost::is_const<T>::value && !boost::is_volatile<T>::value)
91 , boost::true_type, boost::false_type>::type
92 {};
93 #endif
94
95
96 }} // boost::optional_detail
97
98 #endif