NVIDIA DeepStream SDK API Reference

9.2 Release
9.2/includes/opentelemetry/nostd/internal/absl/meta/type_traits.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2008-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef OTABSL_META_TYPE_TRAITS_H_
19 #define OTABSL_META_TYPE_TRAITS_H_
20 
21 #include <stddef.h>
22 #include <functional>
23 #include <type_traits>
24 
25 #include "../base/config.h"
26 
27 // MSVC constructibility traits do not detect destructor properties and so our
28 // implementations should not use them as a source-of-truth.
29 #if defined(_MSC_VER) && !defined(__clang__) && !defined(__GNUC__)
30 #define OTABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION 1
31 #endif
32 
33 namespace absl {
35 
36 // Defined and documented later on in this file.
37 template <typename T>
38 struct is_trivially_destructible;
39 
40 // Defined and documented later on in this file.
41 template <typename T>
42 struct is_trivially_move_assignable;
43 
44 namespace type_traits_internal {
45 
46 // Silence MSVC warnings about the destructor being defined as deleted.
47 #if defined(_MSC_VER) && !defined(__GNUC__)
48 #pragma warning(push)
49 #pragma warning(disable : 4624)
50 #endif // defined(_MSC_VER) && !defined(__GNUC__)
51 
52 template <class T>
53 union SingleMemberUnion {
54  T t;
55 };
56 
57 // Restore the state of the destructor warning that was silenced above.
58 #if defined(_MSC_VER) && !defined(__GNUC__)
59 #pragma warning(pop)
60 #endif // defined(_MSC_VER) && !defined(__GNUC__)
61 
62 template <class T>
63 struct IsTriviallyMoveConstructibleObject
64  : std::integral_constant<
65  bool, std::is_move_constructible<
66  type_traits_internal::SingleMemberUnion<T>>::value &&
67  absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_destructible<T>::value> {};
68 
69 template <class T>
70 struct IsTriviallyCopyConstructibleObject
71  : std::integral_constant<
72  bool, std::is_copy_constructible<
73  type_traits_internal::SingleMemberUnion<T>>::value &&
74  absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_destructible<T>::value> {};
75 
76 template <class T>
77 struct IsTriviallyMoveAssignableReference : std::false_type {};
78 
79 template <class T>
80 struct IsTriviallyMoveAssignableReference<T&>
81  : absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_move_assignable<T>::type {};
82 
83 template <class T>
84 struct IsTriviallyMoveAssignableReference<T&&>
85  : absl::OTABSL_OPTION_NAMESPACE_NAME::is_trivially_move_assignable<T>::type {};
86 
87 template <typename... Ts>
88 struct VoidTImpl {
89  using type = void;
90 };
91 
93 // Library Fundamentals V2 TS //
95 
96 // NOTE: The `is_detected` family of templates here differ from the library
97 // fundamentals specification in that for library fundamentals, `Op<Args...>` is
98 // evaluated as soon as the type `is_detected<Op, Args...>` undergoes
99 // substitution, regardless of whether or not the `::value` is accessed. That
100 // is inconsistent with all other standard traits and prevents lazy evaluation
101 // in larger contexts (such as if the `is_detected` check is a trailing argument
102 // of a `conjunction`. This implementation opts to instead be lazy in the same
103 // way that the standard traits are (this "defect" of the detection idiom
104 // specifications has been reported).
105 
106 template <class Enabler, template <class...> class Op, class... Args>
107 struct is_detected_impl {
109 };
110 
111 template <template <class...> class Op, class... Args>
112 struct is_detected_impl<typename VoidTImpl<Op<Args...>>::type, Op, Args...> {
114 };
115 
116 template <template <class...> class Op, class... Args>
117 struct is_detected : is_detected_impl<void, Op, Args...>::type {};
118 
119 template <class Enabler, class To, template <class...> class Op, class... Args>
120 struct is_detected_convertible_impl {
122 };
123 
124 template <class To, template <class...> class Op, class... Args>
126  typename std::enable_if<std::is_convertible<Op<Args...>, To>::value>::type,
127  To, Op, Args...> {
129 };
130 
131 template <class To, template <class...> class Op, class... Args>
133  : is_detected_convertible_impl<void, To, Op, Args...>::type {};
134 
135 template <typename T>
136 using IsCopyAssignableImpl =
137  decltype(std::declval<T&>() = std::declval<const T&>());
138 
139 template <typename T>
140 using IsMoveAssignableImpl = decltype(std::declval<T&>() = std::declval<T&&>());
141 
142 } // namespace type_traits_internal
143 
144 // MSVC 19.10 and higher have a regression that causes our workarounds to fail, but their
145 // std forms now appear to be compliant.
146 #if defined(_MSC_VER) && !defined(__clang__) && (_MSC_VER >= 1910)
147 
148 template <typename T>
149 using is_copy_assignable = std::is_copy_assignable<T>;
150 
151 template <typename T>
152 using is_move_assignable = std::is_move_assignable<T>;
153 
154 #else
155 
156 template <typename T>
157 struct is_copy_assignable : type_traits_internal::is_detected<
158  type_traits_internal::IsCopyAssignableImpl, T> {
159 };
160 
161 template <typename T>
162 struct is_move_assignable : type_traits_internal::is_detected<
163  type_traits_internal::IsMoveAssignableImpl, T> {
164 };
165 
166 #endif
167 
168 // void_t()
169 //
170 // Ignores the type of any its arguments and returns `void`. In general, this
171 // metafunction allows you to create a general case that maps to `void` while
172 // allowing specializations that map to specific types.
173 //
174 // This metafunction is designed to be a drop-in replacement for the C++17
175 // `std::void_t` metafunction.
176 //
177 // NOTE: `absl::OTABSL_OPTION_NAMESPACE_NAME::void_t` does not use the standard-specified implementation so
178 // that it can remain compatible with gcc < 5.1. This can introduce slightly
179 // different behavior, such as when ordering partial specializations.
180 template <typename... Ts>
181 using void_t = typename type_traits_internal::VoidTImpl<Ts...>::type;
182 
183 // conjunction
184 //
185 // Performs a compile-time logical AND operation on the passed types (which
186 // must have `::value` members convertible to `bool`. Short-circuits if it
187 // encounters any `false` members (and does not compare the `::value` members
188 // of any remaining arguments).
189 //
190 // This metafunction is designed to be a drop-in replacement for the C++17
191 // `std::conjunction` metafunction.
192 template <typename... Ts>
193 struct conjunction;
194 
195 template <typename T, typename... Ts>
196 struct conjunction<T, Ts...>
197  : std::conditional<T::value, conjunction<Ts...>, T>::type {};
198 
199 template <typename T>
200 struct conjunction<T> : T {};
201 
202 template <>
203 struct conjunction<> : std::true_type {};
204 
205 // disjunction
206 //
207 // Performs a compile-time logical OR operation on the passed types (which
208 // must have `::value` members convertible to `bool`. Short-circuits if it
209 // encounters any `true` members (and does not compare the `::value` members
210 // of any remaining arguments).
211 //
212 // This metafunction is designed to be a drop-in replacement for the C++17
213 // `std::disjunction` metafunction.
214 template <typename... Ts>
215 struct disjunction;
216 
217 template <typename T, typename... Ts>
218 struct disjunction<T, Ts...> :
219  std::conditional<T::value, T, disjunction<Ts...>>::type {};
220 
221 template <typename T>
222 struct disjunction<T> : T {};
223 
224 template <>
225 struct disjunction<> : std::false_type {};
226 
227 // negation
228 //
229 // Performs a compile-time logical NOT operation on the passed type (which
230 // must have `::value` members convertible to `bool`.
231 //
232 // This metafunction is designed to be a drop-in replacement for the C++17
233 // `std::negation` metafunction.
234 template <typename T>
235 struct negation : std::integral_constant<bool, !T::value> {};
236 
237 // is_function()
238 //
239 // Determines whether the passed type `T` is a function type.
240 //
241 // This metafunction is designed to be a drop-in replacement for the C++11
242 // `std::is_function()` metafunction for platforms that have incomplete C++11
243 // support (such as libstdc++ 4.x).
244 //
245 // This metafunction works because appending `const` to a type does nothing to
246 // function types and reference types (and forms a const-qualified type
247 // otherwise).
248 template <typename T>
249 struct is_function
250  : std::integral_constant<
251  bool, !(std::is_reference<T>::value ||
252  std::is_const<typename std::add_const<T>::type>::value)> {};
253 
254 // is_trivially_destructible()
255 //
256 // Determines whether the passed type `T` is trivially destructible.
257 //
258 // This metafunction is designed to be a drop-in replacement for the C++11
259 // `std::is_trivially_destructible()` metafunction for platforms that have
260 // incomplete C++11 support (such as libstdc++ 4.x). On any platforms that do
261 // fully support C++11, we check whether this yields the same result as the std
262 // implementation.
263 //
264 // NOTE: the extensions (__has_trivial_xxx) are implemented in gcc (version >=
265 // 4.3) and clang. Since we are supporting libstdc++ > 4.7, they should always
266 // be present. These extensions are documented at
267 // https://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html#Type-Traits.
268 template <typename T>
269 struct is_trivially_destructible
270 #ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
271  : std::is_trivially_destructible<T> {
272 #else
273  : std::integral_constant<bool, __has_trivial_destructor(T) &&
274  std::is_destructible<T>::value> {
275 #endif
276 #ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
277  private:
278  static constexpr bool compliant = std::is_trivially_destructible<T>::value ==
279  is_trivially_destructible::value;
280  static_assert(compliant || std::is_trivially_destructible<T>::value,
281  "Not compliant with std::is_trivially_destructible; "
282  "Standard: false, Implementation: true");
283  static_assert(compliant || !std::is_trivially_destructible<T>::value,
284  "Not compliant with std::is_trivially_destructible; "
285  "Standard: true, Implementation: false");
286 #endif // OTABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
287 };
288 
289 // is_trivially_default_constructible()
290 //
291 // Determines whether the passed type `T` is trivially default constructible.
292 //
293 // This metafunction is designed to be a drop-in replacement for the C++11
294 // `std::is_trivially_default_constructible()` metafunction for platforms that
295 // have incomplete C++11 support (such as libstdc++ 4.x). On any platforms that
296 // do fully support C++11, we check whether this yields the same result as the
297 // std implementation.
298 //
299 // NOTE: according to the C++ standard, Section: 20.15.4.3 [meta.unary.prop]
300 // "The predicate condition for a template specialization is_constructible<T,
301 // Args...> shall be satisfied if and only if the following variable
302 // definition would be well-formed for some invented variable t:
303 //
304 // T t(declval<Args>()...);
305 //
306 // is_trivially_constructible<T, Args...> additionally requires that the
307 // variable definition does not call any operation that is not trivial.
308 // For the purposes of this check, the call to std::declval is considered
309 // trivial."
310 //
311 // Notes from https://en.cppreference.com/w/cpp/types/is_constructible:
312 // In many implementations, is_nothrow_constructible also checks if the
313 // destructor throws because it is effectively noexcept(T(arg)). Same
314 // applies to is_trivially_constructible, which, in these implementations, also
315 // requires that the destructor is trivial.
316 // GCC bug 51452: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51452
317 // LWG issue 2116: http://cplusplus.github.io/LWG/lwg-active.html#2116.
318 //
319 // "T obj();" need to be well-formed and not call any nontrivial operation.
320 // Nontrivially destructible types will cause the expression to be nontrivial.
321 template <typename T>
322 struct is_trivially_default_constructible
323 #if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE)
324  : std::is_trivially_default_constructible<T> {
325 #else
326  : std::integral_constant<bool, __has_trivial_constructor(T) &&
327  std::is_default_constructible<T>::value &&
328  is_trivially_destructible<T>::value> {
329 #endif
330 #if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \
331  !defined( \
332  OTABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION)
333  private:
334  static constexpr bool compliant =
335  std::is_trivially_default_constructible<T>::value ==
336  is_trivially_default_constructible::value;
337  static_assert(compliant || std::is_trivially_default_constructible<T>::value,
338  "Not compliant with std::is_trivially_default_constructible; "
339  "Standard: false, Implementation: true");
340  static_assert(compliant || !std::is_trivially_default_constructible<T>::value,
341  "Not compliant with std::is_trivially_default_constructible; "
342  "Standard: true, Implementation: false");
343 #endif // OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE
344 };
345 
346 // is_trivially_move_constructible()
347 //
348 // Determines whether the passed type `T` is trivially move constructible.
349 //
350 // This metafunction is designed to be a drop-in replacement for the C++11
351 // `std::is_trivially_move_constructible()` metafunction for platforms that have
352 // incomplete C++11 support (such as libstdc++ 4.x). On any platforms that do
353 // fully support C++11, we check whether this yields the same result as the std
354 // implementation.
355 //
356 // NOTE: `T obj(declval<T>());` needs to be well-formed and not call any
357 // nontrivial operation. Nontrivially destructible types will cause the
358 // expression to be nontrivial.
359 template <typename T>
360 struct is_trivially_move_constructible
361 #if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE)
362  : std::is_trivially_move_constructible<T> {
363 #else
364  : std::conditional<
365  std::is_object<T>::value && !std::is_array<T>::value,
366  type_traits_internal::IsTriviallyMoveConstructibleObject<T>,
367  std::is_reference<T>>::type::type {
368 #endif
369 #if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \
370  !defined( \
371  OTABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION)
372  private:
373  static constexpr bool compliant =
374  std::is_trivially_move_constructible<T>::value ==
375  is_trivially_move_constructible::value;
376  static_assert(compliant || std::is_trivially_move_constructible<T>::value,
377  "Not compliant with std::is_trivially_move_constructible; "
378  "Standard: false, Implementation: true");
379  static_assert(compliant || !std::is_trivially_move_constructible<T>::value,
380  "Not compliant with std::is_trivially_move_constructible; "
381  "Standard: true, Implementation: false");
382 #endif // OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE
383 };
384 
385 // is_trivially_copy_constructible()
386 //
387 // Determines whether the passed type `T` is trivially copy constructible.
388 //
389 // This metafunction is designed to be a drop-in replacement for the C++11
390 // `std::is_trivially_copy_constructible()` metafunction for platforms that have
391 // incomplete C++11 support (such as libstdc++ 4.x). On any platforms that do
392 // fully support C++11, we check whether this yields the same result as the std
393 // implementation.
394 //
395 // NOTE: `T obj(declval<const T&>());` needs to be well-formed and not call any
396 // nontrivial operation. Nontrivially destructible types will cause the
397 // expression to be nontrivial.
398 template <typename T>
399 struct is_trivially_copy_constructible
400  : std::conditional<
401  std::is_object<T>::value && !std::is_array<T>::value,
402  type_traits_internal::IsTriviallyCopyConstructibleObject<T>,
403  std::is_lvalue_reference<T>>::type::type {
404 #if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \
405  !defined( \
406  OTABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION)
407  private:
408  static constexpr bool compliant =
409  std::is_trivially_copy_constructible<T>::value ==
410  is_trivially_copy_constructible::value;
411  static_assert(compliant || std::is_trivially_copy_constructible<T>::value,
412  "Not compliant with std::is_trivially_copy_constructible; "
413  "Standard: false, Implementation: true");
414  static_assert(compliant || !std::is_trivially_copy_constructible<T>::value,
415  "Not compliant with std::is_trivially_copy_constructible; "
416  "Standard: true, Implementation: false");
417 #endif // OTABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE
418 };
419 
420 // is_trivially_move_assignable()
421 //
422 // Determines whether the passed type `T` is trivially move assignable.
423 //
424 // This metafunction is designed to be a drop-in replacement for the C++11
425 // `std::is_trivially_move_assignable()` metafunction for platforms that have
426 // incomplete C++11 support (such as libstdc++ 4.x). On any platforms that do
427 // fully support C++11, we check whether this yields the same result as the std
428 // implementation.
429 //
430 // NOTE: `is_assignable<T, U>::value` is `true` if the expression
431 // `declval<T>() = declval<U>()` is well-formed when treated as an unevaluated
432 // operand. `is_trivially_assignable<T, U>` requires the assignment to call no
433 // operation that is not trivial. `is_trivially_copy_assignable<T>` is simply
434 // `is_trivially_assignable<T&, T>`.
435 template <typename T>
436 struct is_trivially_move_assignable
437  : std::conditional<
438  std::is_object<T>::value && !std::is_array<T>::value &&
439  std::is_move_assignable<T>::value,
440  std::is_move_assignable<type_traits_internal::SingleMemberUnion<T>>,
441  type_traits_internal::IsTriviallyMoveAssignableReference<T>>::type::
442  type {
443 #ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
444  private:
445  static constexpr bool compliant =
446  std::is_trivially_move_assignable<T>::value ==
447  is_trivially_move_assignable::value;
448  static_assert(compliant || std::is_trivially_move_assignable<T>::value,
449  "Not compliant with std::is_trivially_move_assignable; "
450  "Standard: false, Implementation: true");
451  static_assert(compliant || !std::is_trivially_move_assignable<T>::value,
452  "Not compliant with std::is_trivially_move_assignable; "
453  "Standard: true, Implementation: false");
454 #endif // OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
455 };
456 
457 // is_trivially_copy_assignable()
458 //
459 // Determines whether the passed type `T` is trivially copy assignable.
460 //
461 // This metafunction is designed to be a drop-in replacement for the C++11
462 // `std::is_trivially_copy_assignable()` metafunction for platforms that have
463 // incomplete C++11 support (such as libstdc++ 4.x). On any platforms that do
464 // fully support C++11, we check whether this yields the same result as the std
465 // implementation.
466 //
467 // NOTE: `is_assignable<T, U>::value` is `true` if the expression
468 // `declval<T>() = declval<U>()` is well-formed when treated as an unevaluated
469 // operand. `is_trivially_assignable<T, U>` requires the assignment to call no
470 // operation that is not trivial. `is_trivially_copy_assignable<T>` is simply
471 // `is_trivially_assignable<T&, const T&>`.
472 template <typename T>
473 struct is_trivially_copy_assignable
474 #ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
475  : std::is_trivially_copy_assignable<T> {
476 #else
477  : std::integral_constant<
478  bool, __has_trivial_assign(typename std::remove_reference<T>::type) &&
479  absl::OTABSL_OPTION_NAMESPACE_NAME::is_copy_assignable<T>::value> {
480 #endif
481 #ifdef OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
482  private:
483  static constexpr bool compliant =
484  std::is_trivially_copy_assignable<T>::value ==
485  is_trivially_copy_assignable::value;
486  static_assert(compliant || std::is_trivially_copy_assignable<T>::value,
487  "Not compliant with std::is_trivially_copy_assignable; "
488  "Standard: false, Implementation: true");
489  static_assert(compliant || !std::is_trivially_copy_assignable<T>::value,
490  "Not compliant with std::is_trivially_copy_assignable; "
491  "Standard: true, Implementation: false");
492 #endif // OTABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
493 };
494 
495 namespace type_traits_internal {
496 // is_trivially_copyable()
497 //
498 // Determines whether the passed type `T` is trivially copyable.
499 //
500 // This metafunction is designed to be a drop-in replacement for the C++11
501 // `std::is_trivially_copyable()` metafunction for platforms that have
502 // incomplete C++11 support (such as libstdc++ 4.x). We use the C++17 definition
503 // of TriviallyCopyable.
504 //
505 // NOTE: `is_trivially_copyable<T>::value` is `true` if all of T's copy/move
506 // constructors/assignment operators are trivial or deleted, T has at least
507 // one non-deleted copy/move constructor/assignment operator, and T is trivially
508 // destructible. Arrays of trivially copyable types are trivially copyable.
509 //
510 // We expose this metafunction only for internal use within absl.
511 
512 #if defined(OTABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE)
513 template <typename T>
514 struct is_trivially_copyable : std::is_trivially_copyable<T> {};
515 #else
516 template <typename T>
517 class is_trivially_copyable_impl {
518  using ExtentsRemoved = typename std::remove_all_extents<T>::type;
519  static constexpr bool kIsCopyOrMoveConstructible =
520  std::is_copy_constructible<ExtentsRemoved>::value ||
521  std::is_move_constructible<ExtentsRemoved>::value;
522  static constexpr bool kIsCopyOrMoveAssignable =
523  absl::OTABSL_OPTION_NAMESPACE_NAME::is_copy_assignable<ExtentsRemoved>::value ||
524  absl::OTABSL_OPTION_NAMESPACE_NAME::is_move_assignable<ExtentsRemoved>::value;
525 
526  public:
527  static constexpr bool kValue =
528  (__has_trivial_copy(ExtentsRemoved) || !kIsCopyOrMoveConstructible) &&
529  (__has_trivial_assign(ExtentsRemoved) || !kIsCopyOrMoveAssignable) &&
530  (kIsCopyOrMoveConstructible || kIsCopyOrMoveAssignable) &&
531  is_trivially_destructible<ExtentsRemoved>::value &&
532  // We need to check for this explicitly because otherwise we'll say
533  // references are trivial copyable when compiled by MSVC.
534  !std::is_reference<ExtentsRemoved>::value;
535 };
536 
537 template <typename T>
538 struct is_trivially_copyable
539  : std::integral_constant<
540  bool, type_traits_internal::is_trivially_copyable_impl<T>::kValue> {};
541 #endif
542 } // namespace type_traits_internal
543 
544 // -----------------------------------------------------------------------------
545 // C++14 "_t" trait aliases
546 // -----------------------------------------------------------------------------
547 
548 template <typename T>
549 using remove_cv_t = typename std::remove_cv<T>::type;
550 
551 template <typename T>
552 using remove_const_t = typename std::remove_const<T>::type;
553 
554 template <typename T>
555 using remove_volatile_t = typename std::remove_volatile<T>::type;
556 
557 template <typename T>
558 using add_cv_t = typename std::add_cv<T>::type;
559 
560 template <typename T>
561 using add_const_t = typename std::add_const<T>::type;
562 
563 template <typename T>
564 using add_volatile_t = typename std::add_volatile<T>::type;
565 
566 template <typename T>
567 using remove_reference_t = typename std::remove_reference<T>::type;
568 
569 template <typename T>
570 using add_lvalue_reference_t = typename std::add_lvalue_reference<T>::type;
571 
572 template <typename T>
573 using add_rvalue_reference_t = typename std::add_rvalue_reference<T>::type;
574 
575 template <typename T>
576 using remove_pointer_t = typename std::remove_pointer<T>::type;
577 
578 template <typename T>
579 using add_pointer_t = typename std::add_pointer<T>::type;
580 
581 template <typename T>
582 using make_signed_t = typename std::make_signed<T>::type;
583 
584 template <typename T>
585 using make_unsigned_t = typename std::make_unsigned<T>::type;
586 
587 template <typename T>
588 using remove_extent_t = typename std::remove_extent<T>::type;
589 
590 template <typename T>
591 using remove_all_extents_t = typename std::remove_all_extents<T>::type;
592 
593 template <typename T>
594 using decay_t = typename std::decay<T>::type;
595 
596 template <bool B, typename T = void>
597 using enable_if_t = typename std::enable_if<B, T>::type;
598 
599 template <bool B, typename T, typename F>
600 using conditional_t = typename std::conditional<B, T, F>::type;
601 
602 template <typename... T>
603 using common_type_t = typename std::common_type<T...>::type;
604 
605 template <typename T>
606 using underlying_type_t = typename std::underlying_type<T>::type;
607 
608 namespace type_traits_internal {
609 
610 #if (!defined(_MSVC_LANG) && (__cplusplus >= 201703L)) || \
611  (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L))
612 // std::result_of is deprecated (C++17) or removed (C++20)
613 template<typename> struct result_of;
614 template<typename F, typename... Args>
615 struct result_of<F(Args...)> : std::invoke_result<F, Args...> {};
616 #else
617 template<typename F> using result_of = std::result_of<F>;
618 #endif
619 
620 } // namespace type_traits_internal
621 
622 template<typename F>
623 using result_of_t = typename type_traits_internal::result_of<F>::type;
624 
625 namespace type_traits_internal {
626 // In MSVC we can't probe std::hash or stdext::hash because it triggers a
627 // static_assert instead of failing substitution. Libc++ prior to 4.0
628 // also used a static_assert.
629 //
630 #if defined(_MSC_VER) || (defined(_LIBCPP_VERSION) && \
631  _LIBCPP_VERSION < 4000 && _LIBCPP_STD_VER > 11)
632 #define OTABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ 0
633 #else
634 #define OTABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_ 1
635 #endif
636 
637 #if !OTABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_
638 template <typename Key, typename = size_t>
639 struct IsHashable : std::true_type {};
640 #else // OTABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_
641 template <typename Key, typename = void>
642 struct IsHashable : std::false_type {};
643 
644 template <typename Key>
645 struct IsHashable<
646  Key,
647  absl::OTABSL_OPTION_NAMESPACE_NAME::enable_if_t<std::is_convertible<
648  decltype(std::declval<std::hash<Key>&>()(std::declval<Key const&>())),
649  std::size_t>::value>> : std::true_type {};
650 #endif // !OTABSL_META_INTERNAL_STD_HASH_SFINAE_FRIENDLY_
651 
652 struct AssertHashEnabledHelper {
653  private:
654  static void Sink(...) {}
655  struct NAT {};
656 
657  template <class Key>
658  static auto GetReturnType(int)
659  -> decltype(std::declval<std::hash<Key>>()(std::declval<Key const&>()));
660  template <class Key>
661  static NAT GetReturnType(...);
662 
663  template <class Key>
664  static std::nullptr_t DoIt() {
665  static_assert(IsHashable<Key>::value,
666  "std::hash<Key> does not provide a call operator");
667  static_assert(
668  std::is_default_constructible<std::hash<Key>>::value,
669  "std::hash<Key> must be default constructible when it is enabled");
670  static_assert(
671  std::is_copy_constructible<std::hash<Key>>::value,
672  "std::hash<Key> must be copy constructible when it is enabled");
673  static_assert(absl::OTABSL_OPTION_NAMESPACE_NAME::is_copy_assignable<std::hash<Key>>::value,
674  "std::hash<Key> must be copy assignable when it is enabled");
675  // is_destructible is unchecked as it's implied by each of the
676  // is_constructible checks.
677  using ReturnType = decltype(GetReturnType<Key>(0));
678  static_assert(std::is_same<ReturnType, NAT>::value ||
679  std::is_same<ReturnType, size_t>::value,
680  "std::hash<Key> must return size_t");
681  return nullptr;
682  }
683 
684  template <class... Ts>
685  friend void AssertHashEnabled();
686 };
687 
688 template <class... Ts>
689 inline void AssertHashEnabled() {
690  using Helper = AssertHashEnabledHelper;
691  Helper::Sink(Helper::DoIt<Ts>()...);
692 }
693 
694 } // namespace type_traits_internal
695 
696 // An internal namespace that is required to implement the C++17 swap traits.
697 // It is not further nested in type_traits_internal to avoid long symbol names.
698 namespace swap_internal {
699 
700 // Necessary for the traits.
701 using std::swap;
702 
703 // This declaration prevents global `swap` and `absl::OTABSL_OPTION_NAMESPACE_NAME::swap` overloads from being
704 // considered unless ADL picks them up.
705 void swap();
706 
707 template <class T>
708 using IsSwappableImpl = decltype(swap(std::declval<T&>(), std::declval<T&>()));
709 
710 // NOTE: This dance with the default template parameter is for MSVC.
711 template <class T,
712  class IsNoexcept = std::integral_constant<
713  bool, noexcept(swap(std::declval<T&>(), std::declval<T&>()))>>
714 using IsNothrowSwappableImpl = typename std::enable_if<IsNoexcept::value>::type;
715 
716 // IsSwappable
717 //
718 // Determines whether the standard swap idiom is a valid expression for
719 // arguments of type `T`.
720 template <class T>
721 struct IsSwappable
722  : absl::OTABSL_OPTION_NAMESPACE_NAME::type_traits_internal::is_detected<IsSwappableImpl, T> {};
723 
724 // IsNothrowSwappable
725 //
726 // Determines whether the standard swap idiom is a valid expression for
727 // arguments of type `T` and is noexcept.
728 template <class T>
729 struct IsNothrowSwappable
730  : absl::OTABSL_OPTION_NAMESPACE_NAME::type_traits_internal::is_detected<IsNothrowSwappableImpl, T> {};
731 
732 // Swap()
733 //
734 // Performs the swap idiom from a namespace where valid candidates may only be
735 // found in `std` or via ADL.
736 template <class T, absl::OTABSL_OPTION_NAMESPACE_NAME::enable_if_t<IsSwappable<T>::value, int> = 0>
737 void Swap(T& lhs, T& rhs) noexcept(IsNothrowSwappable<T>::value) {
738  swap(lhs, rhs);
739 }
740 
741 // StdSwapIsUnconstrained
742 //
743 // Some standard library implementations are broken in that they do not
744 // constrain `std::swap`. This will effectively tell us if we are dealing with
745 // one of those implementations.
746 using StdSwapIsUnconstrained = IsSwappable<void()>;
747 
748 } // namespace swap_internal
749 
750 namespace type_traits_internal {
751 
752 // Make the swap-related traits/function accessible from this namespace.
753 using swap_internal::IsNothrowSwappable;
754 using swap_internal::IsSwappable;
755 using swap_internal::Swap;
757 
758 } // namespace type_traits_internal
760 } // namespace absl
761 
762 #endif // OTABSL_META_TYPE_TRAITS_H_
absl::add_lvalue_reference_t
typename std::add_lvalue_reference< T >::type add_lvalue_reference_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:570
absl::decay_t
typename std::decay< T >::type decay_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:594
absl::remove_all_extents_t
typename std::remove_all_extents< T >::type remove_all_extents_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:591
absl::type_traits_internal::VoidTImpl::type
void type
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:89
absl::type_traits_internal::is_detected_convertible
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:132
absl::type_traits_internal::is_detected_convertible_impl< typename std::enable_if< std::is_convertible< Op< Args... >, To >::value >::type, To, Op, Args... >::type
std::true_type type
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:128
half_float::detail::false_type
bool_type< false > false_type
Definition: includes/half.hpp:489
absl::swap_internal::Swap
void Swap(T &lhs, T &rhs) noexcept(IsNothrowSwappable< T >::value)
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:737
absl::remove_cv_t
typename std::remove_cv< T >::type remove_cv_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:549
absl::swap
void swap(variant< Ts... > &v, variant< Ts... > &w) noexcept(noexcept(v.swap(w)))
Definition: includes/opentelemetry/nostd/internal/absl/types/variant.h:117
absl::type_traits_internal::IsMoveAssignableImpl
decltype(std::declval< T & >()=std::declval< T && >()) IsMoveAssignableImpl
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:140
absl::add_cv_t
typename std::add_cv< T >::type add_cv_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:558
absl::conditional_t
typename std::conditional< B, T, F >::type conditional_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:600
absl::add_const_t
typename std::add_const< T >::type add_const_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:561
absl::enable_if_t
typename std::enable_if< B, T >::type enable_if_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:597
absl::swap_internal::swap
void swap()
absl::swap_internal::StdSwapIsUnconstrained
IsSwappable< void()> StdSwapIsUnconstrained
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:746
absl::make_unsigned_t
typename std::make_unsigned< T >::type make_unsigned_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:585
absl::type_traits_internal::is_detected
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:117
absl::type_traits_internal::VoidTImpl
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:88
absl::remove_const_t
typename std::remove_const< T >::type remove_const_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:552
absl::type_traits_internal::result_of
std::result_of< F > result_of
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:617
absl::add_rvalue_reference_t
typename std::add_rvalue_reference< T >::type add_rvalue_reference_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:573
absl::type_traits_internal::AssertHashEnabled
void AssertHashEnabled()
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:689
absl::make_signed_t
typename std::make_signed< T >::type make_signed_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:582
absl::type_traits_internal::IsCopyAssignableImpl
decltype(std::declval< T & >()=std::declval< const T & >()) IsCopyAssignableImpl
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:137
OTABSL_NAMESPACE_BEGIN
#define OTABSL_NAMESPACE_BEGIN
Definition: includes/opentelemetry/nostd/internal/absl/base/config.h:91
nostd::invoke_result
detail::invoke_result< void, F, Args... > invoke_result
Definition: includes/opentelemetry/nostd/detail/invoke.h:128
absl::remove_pointer_t
typename std::remove_pointer< T >::type remove_pointer_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:576
absl::type_traits_internal::is_detected_impl
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:107
absl::common_type_t
typename std::common_type< T... >::type common_type_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:603
absl::void_t
typename type_traits_internal::VoidTImpl< Ts... >::type void_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:181
half_float::detail::true_type
bool_type< true > true_type
Definition: includes/half.hpp:488
absl::swap_internal::IsNothrowSwappableImpl
typename std::enable_if< IsNoexcept::value >::type IsNothrowSwappableImpl
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:714
absl::type_traits_internal::is_detected_impl< typename VoidTImpl< Op< Args... > >::type, Op, Args... >::type
std::true_type type
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:113
absl::type_traits_internal::is_detected_impl::type
std::false_type type
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:108
nostd::enable_if_t
typename std::enable_if< B, T >::type enable_if_t
Back port of std::enable_if_t.
Definition: includes/opentelemetry/nostd/type_traits.h:40
absl::swap_internal::IsSwappableImpl
decltype(swap(std::declval< T & >(), std::declval< T & >())) IsSwappableImpl
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:708
absl::type_traits_internal::is_detected_convertible_impl::type
std::false_type type
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:121
std
Extensions to the C++ standard library.
Definition: includes/opentelemetry/nostd/string_view.h:212
absl::type_traits_internal::SingleMemberUnion::t
T t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:54
absl::type_traits_internal::is_detected_convertible_impl
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:120
absl::underlying_type_t
typename std::underlying_type< T >::type underlying_type_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:606
absl::add_volatile_t
typename std::add_volatile< T >::type add_volatile_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:564
absl::remove_extent_t
typename std::remove_extent< T >::type remove_extent_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:588
absl
Definition: includes/opentelemetry/nostd/variant.h:54
OTABSL_NAMESPACE_END
#define OTABSL_NAMESPACE_END
Definition: includes/opentelemetry/nostd/internal/absl/base/config.h:92
absl::remove_volatile_t
typename std::remove_volatile< T >::type remove_volatile_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:555
absl::result_of_t
typename type_traits_internal::result_of< F >::type result_of_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:623
absl::remove_reference_t
typename std::remove_reference< T >::type remove_reference_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:567
absl::add_pointer_t
typename std::add_pointer< T >::type add_pointer_t
Definition: includes/opentelemetry/nostd/internal/absl/meta/type_traits.h:579