55
66#include " opentelemetry/version.h"
77
8- #if defined(OPENTELEMETRY_STL_VERSION)
9- # if OPENTELEMETRY_STL_VERSION >= 2011
10- # include " opentelemetry/std/type_traits.h"
11- # define OPENTELEMETRY_HAVE_STD_TYPE_TRAITS
12- # endif
8+ #if !defined(OPENTELEMETRY_STL_VERSION) || (OPENTELEMETRY_STL_VERSION < 2017)
9+ #error OPENTELEMETRY_STL_VERSION must be >= 2017
1310#endif
1411
1512#include < type_traits>
1613
17- #if !defined(OPENTELEMETRY_HAVE_STD_TYPE_TRAITS)
18- # include < array>
19-
20- # include " opentelemetry/nostd/detail/void.h" // IWYU pragma: export
21- #endif
22-
23- #if !defined(__GLIBCXX__) || (defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE >= 7) || \
24- (defined (__GLIBCXX__) && __GLIBCXX__ >= 20150422 ) // >= libstdc++-5
25- # define OPENTELEMETRY_TRIVIALITY_TYPE_TRAITS
26- #endif
27-
2814OPENTELEMETRY_BEGIN_NAMESPACE
2915namespace nostd
3016{
@@ -77,60 +63,8 @@ struct remove_all_extents<std::array<T, N>> : remove_all_extents<T>
7763template <typename T>
7864using remove_all_extents_t = typename remove_all_extents<T>::type;
7965
80- #if defined(OPENTELEMETRY_STL_VERSION) && OPENTELEMETRY_STL_VERSION >= 2017
8166using std::is_nothrow_swappable;
8267using std::is_swappable;
83- #else
84- /* *
85- * Back port of std::is_swappable
86- */
87- namespace detail
88- {
89- namespace swappable
90- {
91-
92- using std::swap;
93-
94- template <typename T>
95- struct is_swappable
96- {
97- private:
98- template <typename U, typename = decltype (swap(std::declval<U &>(), std::declval<U &>()))>
99- inline static std::true_type test (int );
100-
101- template <typename U>
102- inline static std::false_type test (...);
103-
104- public:
105- static constexpr bool value = decltype (test<T>(0 ))::value;
106- };
107-
108- } // namespace swappable
109- } // namespace detail
110-
111- using detail::swappable::is_swappable;
112-
113- /* *
114- * Back port of std::is_swappable
115- */
116- namespace detail
117- {
118- namespace swappable
119- {
120- template <bool IsSwappable, typename T>
121- struct is_nothrow_swappable
122- {
123- static constexpr bool value = noexcept (swap(std::declval<T &>(), std::declval<T &>()));
124- };
125-
126- template <typename T>
127- struct is_nothrow_swappable <false , T> : std::false_type
128- {};
129- } // namespace swappable
130- } // namespace detail
131- template <typename T>
132- using is_nothrow_swappable = detail::swappable::is_nothrow_swappable<is_swappable<T>::value, T>;
133- #endif
13468
13569/* *
13670 * Back port of
@@ -139,35 +73,9 @@ using is_nothrow_swappable = detail::swappable::is_nothrow_swappable<is_swappabl
13973 * std::is_trivialy_copy_assignable
14074 * std::is_trivialy_move_assignable
14175 */
142- #ifdef OPENTELEMETRY_TRIVIALITY_TYPE_TRAITS
14376using std::is_trivially_copy_assignable;
14477using std::is_trivially_copy_constructible;
14578using std::is_trivially_move_assignable;
14679using std::is_trivially_move_constructible;
147- #else
148- template <typename T>
149- struct is_trivially_copy_constructible
150- {
151- static constexpr bool value = std::is_copy_constructible<T>::value && __has_trivial_copy(T);
152- };
153-
154- template <typename T>
155- struct is_trivially_move_constructible
156- {
157- static constexpr bool value = __is_trivial(T);
158- };
159-
160- template <typename T>
161- struct is_trivially_copy_assignable
162- {
163- static constexpr bool value = std::is_copy_assignable<T>::value && __has_trivial_assign(T);
164- };
165-
166- template <typename T>
167- struct is_trivially_move_assignable
168- {
169- static constexpr bool value = __is_trivial(T);
170- };
171- #endif
17280} // namespace nostd
17381OPENTELEMETRY_END_NAMESPACE
0 commit comments