]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/util/type_traits_std.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / util / type_traits_std.hpp
1 // Boost.Geometry
2
3 // Copyright (c) 2020, Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
9
10 #ifndef BOOST_GEOMETRY_UTIL_TYPE_TRAITS_STD_HPP
11 #define BOOST_GEOMETRY_UTIL_TYPE_TRAITS_STD_HPP
12
13
14 #include <cstddef>
15 #include <type_traits>
16
17
18 namespace boost { namespace geometry
19 {
20
21
22 namespace util
23 {
24
25
26 // C++17
27 template <bool B>
28 using bool_constant = std::integral_constant<bool, B>;
29
30 // non-standard
31 template <int I>
32 using int_constant = std::integral_constant<int, I>;
33
34 // non-standard
35 template <std::size_t I>
36 using index_constant = std::integral_constant<std::size_t, I>;
37
38 // non-standard
39 template <std::size_t S>
40 using size_constant = std::integral_constant<std::size_t, S>;
41
42
43 // C++17
44 template <typename ...>
45 struct conjunction
46 : std::true_type
47 {};
48 template<typename Trait>
49 struct conjunction<Trait>
50 : Trait
51 {};
52 template <typename Trait, typename ...Traits>
53 struct conjunction<Trait, Traits...>
54 : std::conditional_t<Trait::value, conjunction<Traits...>, Trait>
55 {};
56
57 // C++17
58 template <typename ...>
59 struct disjunction
60 : std::false_type
61 {};
62 template <typename Trait>
63 struct disjunction<Trait>
64 : Trait
65 {};
66 template <typename Trait, typename ...Traits>
67 struct disjunction<Trait, Traits...>
68 : std::conditional_t<Trait::value, Trait, disjunction<Traits...>>
69 {};
70
71 // C++17
72 template <typename Trait>
73 struct negation
74 : bool_constant<!Trait::value>
75 {};
76
77
78 // non-standard
79 /*
80 template <typename ...Traits>
81 using and_ = conjunction<Traits...>;
82
83 template <typename ...Traits>
84 using or_ = disjunction<Traits...>;
85
86 template <typename Trait>
87 using not_ = negation<Trait>;
88 */
89
90
91 // C++20
92 template <typename T>
93 struct remove_cvref
94 {
95 using type = std::remove_cv_t<std::remove_reference_t<T>>;
96 };
97
98 template <typename T>
99 using remove_cvref_t = typename remove_cvref<T>::type;
100
101 // non-standard
102 template <typename T>
103 struct remove_cref
104 {
105 using type = std::remove_const_t<std::remove_reference_t<T>>;
106 };
107
108 template <typename T>
109 using remove_cref_t = typename remove_cref<T>::type;
110
111 // non-standard
112 template <typename T>
113 struct remove_cptrref
114 {
115 using type = std::remove_const_t
116 <
117 std::remove_pointer_t<std::remove_reference_t<T>>
118 >;
119 };
120
121 template <typename T>
122 using remove_cptrref_t = typename remove_cptrref<T>::type;
123
124
125 // non-standard
126 template <typename From, typename To>
127 struct transcribe_const
128 {
129 using type = std::conditional_t
130 <
131 std::is_const<std::remove_reference_t<From>>::value,
132 std::add_const_t<To>,
133 To
134 >;
135 };
136
137 template <typename From, typename To>
138 using transcribe_const_t = typename transcribe_const<From, To>::type;
139
140
141 } // namespace util
142
143
144 // Deprecated utilities, defined for backward compatibility but might be
145 // removed in the future.
146
147
148 /*!
149 \brief Meta-function to define a const or non const type
150 \ingroup utility
151 \details If the boolean template parameter is true, the type parameter
152 will be defined as const, otherwise it will be defined as it was.
153 This meta-function is used to have one implementation for both
154 const and non const references
155 \note This traits class is completely independant from Boost.Geometry
156 and might be a separate addition to Boost
157 \note Used in a.o. for_each, interior_rings, exterior_ring
158 \par Example
159 \code
160 void foo(typename add_const_if_c<IsConst, Point>::type& point)
161 \endcode
162 */
163 template <bool IsConst, typename Type>
164 struct add_const_if_c
165 {
166 typedef std::conditional_t
167 <
168 IsConst,
169 Type const,
170 Type
171 > type;
172 };
173
174
175 namespace util
176 {
177
178 template <typename T>
179 using bare_type = remove_cptrref<T>;
180
181 } // namespace util
182
183
184 }} // namespace boost::geometry
185
186 #endif // BOOST_GEOMETRY_UTIL_TYPE_TRAITS_STD_HPP