| // -*- C++ -*- |
| //===----------------------------------------------------------------------===// |
| // |
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| // See https://llvm.org/LICENSE.txt for license information. |
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| // |
| //===----------------------------------------------------------------------===// |
| |
| #ifndef _LIBCPP_TYPE_TRAITS |
| #define _LIBCPP_TYPE_TRAITS |
| |
| /* |
| type_traits synopsis |
| |
| namespace std |
| { |
| |
| // helper class: |
| template <class T, T v> struct integral_constant; |
| typedef integral_constant<bool, true> true_type; // C++11 |
| typedef integral_constant<bool, false> false_type; // C++11 |
| |
| template <bool B> // C++14 |
| using bool_constant = integral_constant<bool, B>; // C++14 |
| typedef bool_constant<true> true_type; // C++14 |
| typedef bool_constant<false> false_type; // C++14 |
| |
| // helper traits |
| template <bool, class T = void> struct enable_if; |
| template <bool, class T, class F> struct conditional; |
| |
| // Primary classification traits: |
| template <class T> struct is_void; |
| template <class T> struct is_null_pointer; // C++14 |
| template <class T> struct is_integral; |
| template <class T> struct is_floating_point; |
| template <class T> struct is_array; |
| template <class T> struct is_pointer; |
| template <class T> struct is_lvalue_reference; |
| template <class T> struct is_rvalue_reference; |
| template <class T> struct is_member_object_pointer; |
| template <class T> struct is_member_function_pointer; |
| template <class T> struct is_enum; |
| template <class T> struct is_union; |
| template <class T> struct is_class; |
| template <class T> struct is_function; |
| |
| // Secondary classification traits: |
| template <class T> struct is_reference; |
| template <class T> struct is_arithmetic; |
| template <class T> struct is_fundamental; |
| template <class T> struct is_member_pointer; |
| template <class T> struct is_scoped_enum; // C++2b |
| template <class T> struct is_scalar; |
| template <class T> struct is_object; |
| template <class T> struct is_compound; |
| |
| // Const-volatile properties and transformations: |
| template <class T> struct is_const; |
| template <class T> struct is_volatile; |
| template <class T> struct remove_const; |
| template <class T> struct remove_volatile; |
| template <class T> struct remove_cv; |
| template <class T> struct add_const; |
| template <class T> struct add_volatile; |
| template <class T> struct add_cv; |
| |
| // Reference transformations: |
| template <class T> struct remove_reference; |
| template <class T> struct add_lvalue_reference; |
| template <class T> struct add_rvalue_reference; |
| |
| // Pointer transformations: |
| template <class T> struct remove_pointer; |
| template <class T> struct add_pointer; |
| |
| template<class T> struct type_identity; // C++20 |
| template<class T> |
| using type_identity_t = typename type_identity<T>::type; // C++20 |
| |
| // Integral properties: |
| template <class T> struct is_signed; |
| template <class T> struct is_unsigned; |
| template <class T> struct make_signed; |
| template <class T> struct make_unsigned; |
| |
| // Array properties and transformations: |
| template <class T> struct rank; |
| template <class T, unsigned I = 0> struct extent; |
| template <class T> struct remove_extent; |
| template <class T> struct remove_all_extents; |
| |
| template <class T> struct is_bounded_array; // C++20 |
| template <class T> struct is_unbounded_array; // C++20 |
| |
| // Member introspection: |
| template <class T> struct is_pod; |
| template <class T> struct is_trivial; |
| template <class T> struct is_trivially_copyable; |
| template <class T> struct is_standard_layout; |
| template <class T> struct is_literal_type; // Deprecated in C++17; removed in C++20 |
| template <class T> struct is_empty; |
| template <class T> struct is_polymorphic; |
| template <class T> struct is_abstract; |
| template <class T> struct is_final; // C++14 |
| template <class T> struct is_aggregate; // C++17 |
| |
| template <class T, class... Args> struct is_constructible; |
| template <class T> struct is_default_constructible; |
| template <class T> struct is_copy_constructible; |
| template <class T> struct is_move_constructible; |
| template <class T, class U> struct is_assignable; |
| template <class T> struct is_copy_assignable; |
| template <class T> struct is_move_assignable; |
| template <class T, class U> struct is_swappable_with; // C++17 |
| template <class T> struct is_swappable; // C++17 |
| template <class T> struct is_destructible; |
| |
| template <class T, class... Args> struct is_trivially_constructible; |
| template <class T> struct is_trivially_default_constructible; |
| template <class T> struct is_trivially_copy_constructible; |
| template <class T> struct is_trivially_move_constructible; |
| template <class T, class U> struct is_trivially_assignable; |
| template <class T> struct is_trivially_copy_assignable; |
| template <class T> struct is_trivially_move_assignable; |
| template <class T> struct is_trivially_destructible; |
| |
| template <class T, class... Args> struct is_nothrow_constructible; |
| template <class T> struct is_nothrow_default_constructible; |
| template <class T> struct is_nothrow_copy_constructible; |
| template <class T> struct is_nothrow_move_constructible; |
| template <class T, class U> struct is_nothrow_assignable; |
| template <class T> struct is_nothrow_copy_assignable; |
| template <class T> struct is_nothrow_move_assignable; |
| template <class T, class U> struct is_nothrow_swappable_with; // C++17 |
| template <class T> struct is_nothrow_swappable; // C++17 |
| template <class T> struct is_nothrow_destructible; |
| |
| template <class T> struct has_virtual_destructor; |
| |
| template<class T> struct has_unique_object_representations; // C++17 |
| |
| // Relationships between types: |
| template <class T, class U> struct is_same; |
| template <class Base, class Derived> struct is_base_of; |
| |
| template <class From, class To> struct is_convertible; |
| template <typename From, typename To> struct is_nothrow_convertible; // C++20 |
| template <typename From, typename To> inline constexpr bool is_nothrow_convertible_v; // C++20 |
| |
| template <class Fn, class... ArgTypes> struct is_invocable; |
| template <class R, class Fn, class... ArgTypes> struct is_invocable_r; |
| |
| template <class Fn, class... ArgTypes> struct is_nothrow_invocable; |
| template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r; |
| |
| // Alignment properties and transformations: |
| template <class T> struct alignment_of; |
| template <size_t Len, size_t Align = most_stringent_alignment_requirement> |
| struct aligned_storage; |
| template <size_t Len, class... Types> struct aligned_union; |
| template <class T> struct remove_cvref; // C++20 |
| |
| template <class T> struct decay; |
| template <class... T> struct common_type; |
| template <class T> struct underlying_type; |
| template <class> class result_of; // undefined; deprecated in C++17; removed in C++20 |
| template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>; // deprecated in C++17; removed in C++20 |
| template <class Fn, class... ArgTypes> struct invoke_result; // C++17 |
| |
| // const-volatile modifications: |
| template <class T> |
| using remove_const_t = typename remove_const<T>::type; // C++14 |
| template <class T> |
| using remove_volatile_t = typename remove_volatile<T>::type; // C++14 |
| template <class T> |
| using remove_cv_t = typename remove_cv<T>::type; // C++14 |
| template <class T> |
| using add_const_t = typename add_const<T>::type; // C++14 |
| template <class T> |
| using add_volatile_t = typename add_volatile<T>::type; // C++14 |
| template <class T> |
| using add_cv_t = typename add_cv<T>::type; // C++14 |
| |
| // reference modifications: |
| template <class T> |
| using remove_reference_t = typename remove_reference<T>::type; // C++14 |
| template <class T> |
| using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14 |
| template <class T> |
| using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14 |
| |
| // sign modifications: |
| template <class T> |
| using make_signed_t = typename make_signed<T>::type; // C++14 |
| template <class T> |
| using make_unsigned_t = typename make_unsigned<T>::type; // C++14 |
| |
| // array modifications: |
| template <class T> |
| using remove_extent_t = typename remove_extent<T>::type; // C++14 |
| template <class T> |
| using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14 |
| |
| template <class T> |
| inline constexpr bool is_bounded_array_v |
| = is_bounded_array<T>::value; // C++20 |
| inline constexpr bool is_unbounded_array_v |
| = is_unbounded_array<T>::value; // C++20 |
| |
| // pointer modifications: |
| template <class T> |
| using remove_pointer_t = typename remove_pointer<T>::type; // C++14 |
| template <class T> |
| using add_pointer_t = typename add_pointer<T>::type; // C++14 |
| |
| // other transformations: |
| template <size_t Len, size_t Align=default-alignment> |
| using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14 |
| template <size_t Len, class... Types> |
| using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14 |
| template <class T> |
| using remove_cvref_t = typename remove_cvref<T>::type; // C++20 |
| template <class T> |
| using decay_t = typename decay<T>::type; // C++14 |
| template <bool b, class T=void> |
| using enable_if_t = typename enable_if<b,T>::type; // C++14 |
| template <bool b, class T, class F> |
| using conditional_t = typename conditional<b,T,F>::type; // C++14 |
| template <class... T> |
| using common_type_t = typename common_type<T...>::type; // C++14 |
| template <class T> |
| using underlying_type_t = typename underlying_type<T>::type; // C++14 |
| template <class T> |
| using result_of_t = typename result_of<T>::type; // C++14; deprecated in C++17; removed in C++20 |
| template <class Fn, class... ArgTypes> |
| using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17 |
| |
| template <class...> |
| using void_t = void; // C++17 |
| |
| // See C++14 20.10.4.1, primary type categories |
| template <class T> inline constexpr bool is_void_v |
| = is_void<T>::value; // C++17 |
| template <class T> inline constexpr bool is_null_pointer_v |
| = is_null_pointer<T>::value; // C++17 |
| template <class T> inline constexpr bool is_integral_v |
| = is_integral<T>::value; // C++17 |
| template <class T> inline constexpr bool is_floating_point_v |
| = is_floating_point<T>::value; // C++17 |
| template <class T> inline constexpr bool is_array_v |
| = is_array<T>::value; // C++17 |
| template <class T> inline constexpr bool is_pointer_v |
| = is_pointer<T>::value; // C++17 |
| template <class T> inline constexpr bool is_lvalue_reference_v |
| = is_lvalue_reference<T>::value; // C++17 |
| template <class T> inline constexpr bool is_rvalue_reference_v |
| = is_rvalue_reference<T>::value; // C++17 |
| template <class T> inline constexpr bool is_member_object_pointer_v |
| = is_member_object_pointer<T>::value; // C++17 |
| template <class T> inline constexpr bool is_member_function_pointer_v |
| = is_member_function_pointer<T>::value; // C++17 |
| template <class T> inline constexpr bool is_enum_v |
| = is_enum<T>::value; // C++17 |
| template <class T> inline constexpr bool is_union_v |
| = is_union<T>::value; // C++17 |
| template <class T> inline constexpr bool is_class_v |
| = is_class<T>::value; // C++17 |
| template <class T> inline constexpr bool is_function_v |
| = is_function<T>::value; // C++17 |
| |
| // See C++14 20.10.4.2, composite type categories |
| template <class T> inline constexpr bool is_reference_v |
| = is_reference<T>::value; // C++17 |
| template <class T> inline constexpr bool is_arithmetic_v |
| = is_arithmetic<T>::value; // C++17 |
| template <class T> inline constexpr bool is_fundamental_v |
| = is_fundamental<T>::value; // C++17 |
| template <class T> inline constexpr bool is_object_v |
| = is_object<T>::value; // C++17 |
| template <class T> inline constexpr bool is_scalar_v |
| = is_scalar<T>::value; // C++17 |
| template <class T> inline constexpr bool is_compound_v |
| = is_compound<T>::value; // C++17 |
| template <class T> inline constexpr bool is_member_pointer_v |
| = is_member_pointer<T>::value; // C++17 |
| template <class T> inline constexpr bool is_scoped_enum_v |
| = is_scoped_enum<T>::value; // C++2b |
| |
| // See C++14 20.10.4.3, type properties |
| template <class T> inline constexpr bool is_const_v |
| = is_const<T>::value; // C++17 |
| template <class T> inline constexpr bool is_volatile_v |
| = is_volatile<T>::value; // C++17 |
| template <class T> inline constexpr bool is_trivial_v |
| = is_trivial<T>::value; // C++17 |
| template <class T> inline constexpr bool is_trivially_copyable_v |
| = is_trivially_copyable<T>::value; // C++17 |
| template <class T> inline constexpr bool is_standard_layout_v |
| = is_standard_layout<T>::value; // C++17 |
| template <class T> inline constexpr bool is_pod_v |
| = is_pod<T>::value; // C++17 |
| template <class T> inline constexpr bool is_literal_type_v |
| = is_literal_type<T>::value; // C++17; deprecated in C++17; removed in C++20 |
| template <class T> inline constexpr bool is_empty_v |
| = is_empty<T>::value; // C++17 |
| template <class T> inline constexpr bool is_polymorphic_v |
| = is_polymorphic<T>::value; // C++17 |
| template <class T> inline constexpr bool is_abstract_v |
| = is_abstract<T>::value; // C++17 |
| template <class T> inline constexpr bool is_final_v |
| = is_final<T>::value; // C++17 |
| template <class T> inline constexpr bool is_aggregate_v |
| = is_aggregate<T>::value; // C++17 |
| template <class T> inline constexpr bool is_signed_v |
| = is_signed<T>::value; // C++17 |
| template <class T> inline constexpr bool is_unsigned_v |
| = is_unsigned<T>::value; // C++17 |
| template <class T, class... Args> inline constexpr bool is_constructible_v |
| = is_constructible<T, Args...>::value; // C++17 |
| template <class T> inline constexpr bool is_default_constructible_v |
| = is_default_constructible<T>::value; // C++17 |
| template <class T> inline constexpr bool is_copy_constructible_v |
| = is_copy_constructible<T>::value; // C++17 |
| template <class T> inline constexpr bool is_move_constructible_v |
| = is_move_constructible<T>::value; // C++17 |
| template <class T, class U> inline constexpr bool is_assignable_v |
| = is_assignable<T, U>::value; // C++17 |
| template <class T> inline constexpr bool is_copy_assignable_v |
| = is_copy_assignable<T>::value; // C++17 |
| template <class T> inline constexpr bool is_move_assignable_v |
| = is_move_assignable<T>::value; // C++17 |
| template <class T, class U> inline constexpr bool is_swappable_with_v |
| = is_swappable_with<T, U>::value; // C++17 |
| template <class T> inline constexpr bool is_swappable_v |
| = is_swappable<T>::value; // C++17 |
| template <class T> inline constexpr bool is_destructible_v |
| = is_destructible<T>::value; // C++17 |
| template <class T, class... Args> inline constexpr bool is_trivially_constructible_v |
| = is_trivially_constructible<T, Args...>::value; // C++17 |
| template <class T> inline constexpr bool is_trivially_default_constructible_v |
| = is_trivially_default_constructible<T>::value; // C++17 |
| template <class T> inline constexpr bool is_trivially_copy_constructible_v |
| = is_trivially_copy_constructible<T>::value; // C++17 |
| template <class T> inline constexpr bool is_trivially_move_constructible_v |
| = is_trivially_move_constructible<T>::value; // C++17 |
| template <class T, class U> inline constexpr bool is_trivially_assignable_v |
| = is_trivially_assignable<T, U>::value; // C++17 |
| template <class T> inline constexpr bool is_trivially_copy_assignable_v |
| = is_trivially_copy_assignable<T>::value; // C++17 |
| template <class T> inline constexpr bool is_trivially_move_assignable_v |
| = is_trivially_move_assignable<T>::value; // C++17 |
| template <class T> inline constexpr bool is_trivially_destructible_v |
| = is_trivially_destructible<T>::value; // C++17 |
| template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v |
| = is_nothrow_constructible<T, Args...>::value; // C++17 |
| template <class T> inline constexpr bool is_nothrow_default_constructible_v |
| = is_nothrow_default_constructible<T>::value; // C++17 |
| template <class T> inline constexpr bool is_nothrow_copy_constructible_v |
| = is_nothrow_copy_constructible<T>::value; // C++17 |
| template <class T> inline constexpr bool is_nothrow_move_constructible_v |
| = is_nothrow_move_constructible<T>::value; // C++17 |
| template <class T, class U> inline constexpr bool is_nothrow_assignable_v |
| = is_nothrow_assignable<T, U>::value; // C++17 |
| template <class T> inline constexpr bool is_nothrow_copy_assignable_v |
| = is_nothrow_copy_assignable<T>::value; // C++17 |
| template <class T> inline constexpr bool is_nothrow_move_assignable_v |
| = is_nothrow_move_assignable<T>::value; // C++17 |
| template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v |
| = is_nothrow_swappable_with<T, U>::value; // C++17 |
| template <class T> inline constexpr bool is_nothrow_swappable_v |
| = is_nothrow_swappable<T>::value; // C++17 |
| template <class T> inline constexpr bool is_nothrow_destructible_v |
| = is_nothrow_destructible<T>::value; // C++17 |
| template <class T> inline constexpr bool has_virtual_destructor_v |
| = has_virtual_destructor<T>::value; // C++17 |
| template<class T> inline constexpr bool has_unique_object_representations_v // C++17 |
| = has_unique_object_representations<T>::value; |
| |
| // See C++14 20.10.5, type property queries |
| template <class T> inline constexpr size_t alignment_of_v |
| = alignment_of<T>::value; // C++17 |
| template <class T> inline constexpr size_t rank_v |
| = rank<T>::value; // C++17 |
| template <class T, unsigned I = 0> inline constexpr size_t extent_v |
| = extent<T, I>::value; // C++17 |
| |
| // See C++14 20.10.6, type relations |
| template <class T, class U> inline constexpr bool is_same_v |
| = is_same<T, U>::value; // C++17 |
| template <class Base, class Derived> inline constexpr bool is_base_of_v |
| = is_base_of<Base, Derived>::value; // C++17 |
| template <class From, class To> inline constexpr bool is_convertible_v |
| = is_convertible<From, To>::value; // C++17 |
| template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v |
| = is_invocable<Fn, ArgTypes...>::value; // C++17 |
| template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v |
| = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17 |
| template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v |
| = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17 |
| template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v |
| = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17 |
| |
| // [meta.logical], logical operator traits: |
| template<class... B> struct conjunction; // C++17 |
| template<class... B> |
| inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17 |
| template<class... B> struct disjunction; // C++17 |
| template<class... B> |
| inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17 |
| template<class B> struct negation; // C++17 |
| template<class B> |
| inline constexpr bool negation_v = negation<B>::value; // C++17 |
| |
| } |
| |
| */ |
| #include <__assert> // all public C++ headers provide the assertion handler |
| #include <__config> |
| #include <__functional/invoke.h> |
| #include <__type_traits/add_const.h> |
| #include <__type_traits/add_cv.h> |
| #include <__type_traits/add_lvalue_reference.h> |
| #include <__type_traits/add_pointer.h> |
| #include <__type_traits/add_rvalue_reference.h> |
| #include <__type_traits/add_volatile.h> |
| #include <__type_traits/alignment_of.h> |
| #include <__type_traits/apply_cv.h> |
| #include <__type_traits/conditional.h> |
| #include <__type_traits/conjunction.h> |
| #include <__type_traits/decay.h> |
| #include <__type_traits/disjunction.h> |
| #include <__type_traits/enable_if.h> |
| #include <__type_traits/extent.h> |
| #include <__type_traits/has_unique_object_representation.h> |
| #include <__type_traits/has_virtual_destructor.h> |
| #include <__type_traits/integral_constant.h> |
| #include <__type_traits/is_abstract.h> |
| #include <__type_traits/is_aggregate.h> |
| #include <__type_traits/is_arithmetic.h> |
| #include <__type_traits/is_array.h> |
| #include <__type_traits/is_assignable.h> |
| #include <__type_traits/is_base_of.h> |
| #include <__type_traits/is_bounded_array.h> |
| #include <__type_traits/is_callable.h> |
| #include <__type_traits/is_class.h> |
| #include <__type_traits/is_compound.h> |
| #include <__type_traits/is_const.h> |
| #include <__type_traits/is_constant_evaluated.h> |
| #include <__type_traits/is_constructible.h> |
| #include <__type_traits/is_convertible.h> |
| #include <__type_traits/is_copy_assignable.h> |
| #include <__type_traits/is_copy_constructible.h> |
| #include <__type_traits/is_default_constructible.h> |
| #include <__type_traits/is_destructible.h> |
| #include <__type_traits/is_empty.h> |
| #include <__type_traits/is_enum.h> |
| #include <__type_traits/is_final.h> |
| #include <__type_traits/is_floating_point.h> |
| #include <__type_traits/is_function.h> |
| #include <__type_traits/is_fundamental.h> |
| #include <__type_traits/is_integral.h> |
| #include <__type_traits/is_literal_type.h> |
| #include <__type_traits/is_member_function_pointer.h> |
| #include <__type_traits/is_member_object_pointer.h> |
| #include <__type_traits/is_member_pointer.h> |
| #include <__type_traits/is_move_assignable.h> |
| #include <__type_traits/is_move_constructible.h> |
| #include <__type_traits/is_nothrow_assignable.h> |
| #include <__type_traits/is_nothrow_constructible.h> |
| #include <__type_traits/is_nothrow_copy_assignable.h> |
| #include <__type_traits/is_nothrow_copy_constructible.h> |
| #include <__type_traits/is_nothrow_default_constructible.h> |
| #include <__type_traits/is_nothrow_destructible.h> |
| #include <__type_traits/is_nothrow_move_assignable.h> |
| #include <__type_traits/is_nothrow_move_constructible.h> |
| #include <__type_traits/is_null_pointer.h> |
| #include <__type_traits/is_object.h> |
| #include <__type_traits/is_pod.h> |
| #include <__type_traits/is_pointer.h> |
| #include <__type_traits/is_polymorphic.h> |
| #include <__type_traits/is_reference.h> |
| #include <__type_traits/is_reference_wrapper.h> |
| #include <__type_traits/is_referenceable.h> |
| #include <__type_traits/is_same.h> |
| #include <__type_traits/is_scalar.h> |
| #include <__type_traits/is_scoped_enum.h> |
| #include <__type_traits/is_signed.h> |
| #include <__type_traits/is_standard_layout.h> |
| #include <__type_traits/is_trivial.h> |
| #include <__type_traits/is_trivially_assignable.h> |
| #include <__type_traits/is_trivially_constructible.h> |
| #include <__type_traits/is_trivially_copy_assignable.h> |
| #include <__type_traits/is_trivially_copy_constructible.h> |
| #include <__type_traits/is_trivially_copyable.h> |
| #include <__type_traits/is_trivially_default_constructible.h> |
| #include <__type_traits/is_trivially_destructible.h> |
| #include <__type_traits/is_trivially_move_assignable.h> |
| #include <__type_traits/is_trivially_move_constructible.h> |
| #include <__type_traits/is_unbounded_array.h> |
| #include <__type_traits/is_union.h> |
| #include <__type_traits/is_unsigned.h> |
| #include <__type_traits/is_void.h> |
| #include <__type_traits/is_volatile.h> |
| #include <__type_traits/negation.h> |
| #include <__type_traits/rank.h> |
| #include <__type_traits/remove_all_extents.h> |
| #include <__type_traits/remove_const.h> |
| #include <__type_traits/remove_cv.h> |
| #include <__type_traits/remove_extent.h> |
| #include <__type_traits/remove_pointer.h> |
| #include <__type_traits/remove_reference.h> |
| #include <__type_traits/remove_volatile.h> |
| #include <__type_traits/type_identity.h> |
| #include <__type_traits/underlying_type.h> |
| #include <__type_traits/void_t.h> |
| #include <__utility/declval.h> |
| #include <cstddef> |
| #include <version> |
| |
| #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| # pragma GCC system_header |
| #endif |
| |
| _LIBCPP_BEGIN_NAMESPACE_STD |
| |
| template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair; |
| template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash; |
| |
| template <bool> struct _MetaBase; |
| template <> |
| struct _MetaBase<true> { |
| template <class _Tp, class _Up> |
| using _SelectImpl _LIBCPP_NODEBUG = _Tp; |
| template <template <class...> class _FirstFn, template <class...> class, class ..._Args> |
| using _SelectApplyImpl _LIBCPP_NODEBUG = _FirstFn<_Args...>; |
| template <class _First, class...> |
| using _FirstImpl _LIBCPP_NODEBUG = _First; |
| template <class, class _Second, class...> |
| using _SecondImpl _LIBCPP_NODEBUG = _Second; |
| template <class _Result, class _First, class ..._Rest> |
| using _OrImpl _LIBCPP_NODEBUG = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>; |
| }; |
| |
| template <> |
| struct _MetaBase<false> { |
| template <class _Tp, class _Up> |
| using _SelectImpl _LIBCPP_NODEBUG = _Up; |
| template <template <class...> class, template <class...> class _SecondFn, class ..._Args> |
| using _SelectApplyImpl _LIBCPP_NODEBUG = _SecondFn<_Args...>; |
| template <class _Result, class ...> |
| using _OrImpl _LIBCPP_NODEBUG = _Result; |
| }; |
| template <bool _Cond, class _IfRes, class _ElseRes> |
| using _If _LIBCPP_NODEBUG = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>; |
| template <class ..._Rest> |
| using _Or _LIBCPP_NODEBUG = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>; |
| template <class ..._Args> |
| using _FirstType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>; |
| template <class ..._Args> |
| using _SecondType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>; |
| |
| template <class ...> using __expand_to_true = true_type; |
| template <class ..._Pred> |
| __expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int); |
| template <class ...> |
| false_type __and_helper(...); |
| template <class ..._Pred> |
| using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0)); |
| |
| template <template <class...> class _Func, class ..._Args> |
| struct _Lazy : _Func<_Args...> {}; |
| |
| // Member detector base |
| |
| template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> > |
| true_type __sfinae_test_impl(int); |
| template <template <class...> class, class ...> |
| false_type __sfinae_test_impl(...); |
| |
| template <template <class ...> class _Templ, class ..._Args> |
| using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0)); |
| |
| template <class _Tp, bool> |
| struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {}; |
| |
| // is_same |
| |
| template <class _Tp> |
| using __test_for_primary_template = __enable_if_t< |
| _IsSame<_Tp, typename _Tp::__primary_template>::value |
| >; |
| template <class _Tp> |
| using __is_primary_template = _IsValidExpansion< |
| __test_for_primary_template, _Tp |
| >; |
| |
| // is_integral |
| |
| // [basic.fundamental] defines five standard signed integer types; |
| // __int128_t is an extended signed integer type. |
| // The signed and unsigned integer types, plus bool and the |
| // five types with "char" in their name, compose the "integral" types. |
| |
| template <class _Tp> struct __libcpp_is_signed_integer : public false_type {}; |
| template <> struct __libcpp_is_signed_integer<signed char> : public true_type {}; |
| template <> struct __libcpp_is_signed_integer<signed short> : public true_type {}; |
| template <> struct __libcpp_is_signed_integer<signed int> : public true_type {}; |
| template <> struct __libcpp_is_signed_integer<signed long> : public true_type {}; |
| template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {}; |
| #ifndef _LIBCPP_HAS_NO_INT128 |
| template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {}; |
| #endif |
| |
| template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {}; |
| template <> struct __libcpp_is_unsigned_integer<unsigned char> : public true_type {}; |
| template <> struct __libcpp_is_unsigned_integer<unsigned short> : public true_type {}; |
| template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {}; |
| template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {}; |
| template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {}; |
| #ifndef _LIBCPP_HAS_NO_INT128 |
| template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {}; |
| #endif |
| |
| template <class _Tp> |
| struct __unconstref { |
| typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type; |
| }; |
| |
| template <class _Tp> |
| using __uncvref_t _LIBCPP_NODEBUG = typename remove_cv<typename remove_reference<_Tp>::type>::type; |
| |
| // __is_same_uncvref |
| |
| template <class _Tp, class _Up> |
| struct __is_same_uncvref : _IsSame<__uncvref_t<_Tp>, __uncvref_t<_Up> > {}; |
| |
| #if _LIBCPP_STD_VER > 17 |
| // remove_cvref - same as __uncvref |
| template <class _Tp> |
| struct remove_cvref { |
| using type _LIBCPP_NODEBUG = __uncvref_t<_Tp>; |
| }; |
| |
| template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type; |
| #endif |
| |
| // is_nothrow_convertible |
| |
| #if _LIBCPP_STD_VER > 17 |
| |
| template <typename _Tp> |
| static void __test_noexcept(_Tp) noexcept; |
| |
| template<typename _Fm, typename _To> |
| static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))> |
| __is_nothrow_convertible_test(); |
| |
| template <typename _Fm, typename _To> |
| struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>()) |
| { }; |
| |
| template <typename _Fm, typename _To> |
| struct is_nothrow_convertible : _Or< |
| _And<is_void<_To>, is_void<_Fm>>, |
| _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>> |
| >::type { }; |
| |
| template <typename _Fm, typename _To> |
| inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value; |
| |
| #endif // _LIBCPP_STD_VER > 17 |
| |
| // aligned_storage |
| |
| template <class _Hp, class _Tp> |
| struct __type_list |
| { |
| typedef _Hp _Head; |
| typedef _Tp _Tail; |
| }; |
| |
| template <class _Tp> |
| struct __align_type |
| { |
| static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp); |
| typedef _Tp type; |
| }; |
| |
| struct __struct_double {long double __lx;}; |
| struct __struct_double4 {double __lx[4];}; |
| |
| typedef |
| __type_list<__align_type<unsigned char>, |
| __type_list<__align_type<unsigned short>, |
| __type_list<__align_type<unsigned int>, |
| __type_list<__align_type<unsigned long>, |
| __type_list<__align_type<unsigned long long>, |
| __type_list<__align_type<double>, |
| __type_list<__align_type<long double>, |
| __type_list<__align_type<__struct_double>, |
| __type_list<__align_type<__struct_double4>, |
| __type_list<__align_type<int*>, |
| __nat |
| > > > > > > > > > > __all_types; |
| |
| template <size_t _Align> |
| struct _ALIGNAS(_Align) __fallback_overaligned {}; |
| |
| template <class _TL, size_t _Align> struct __find_pod; |
| |
| template <class _Hp, size_t _Align> |
| struct __find_pod<__type_list<_Hp, __nat>, _Align> |
| { |
| typedef typename conditional< |
| _Align == _Hp::value, |
| typename _Hp::type, |
| __fallback_overaligned<_Align> |
| >::type type; |
| }; |
| |
| template <class _Hp, class _Tp, size_t _Align> |
| struct __find_pod<__type_list<_Hp, _Tp>, _Align> |
| { |
| typedef typename conditional< |
| _Align == _Hp::value, |
| typename _Hp::type, |
| typename __find_pod<_Tp, _Align>::type |
| >::type type; |
| }; |
| |
| template <class _TL, size_t _Len> struct __find_max_align; |
| |
| template <class _Hp, size_t _Len> |
| struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {}; |
| |
| template <size_t _Len, size_t _A1, size_t _A2> |
| struct __select_align |
| { |
| private: |
| static const size_t __min = _A2 < _A1 ? _A2 : _A1; |
| static const size_t __max = _A1 < _A2 ? _A2 : _A1; |
| public: |
| static const size_t value = _Len < __max ? __min : __max; |
| }; |
| |
| template <class _Hp, class _Tp, size_t _Len> |
| struct __find_max_align<__type_list<_Hp, _Tp>, _Len> |
| : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; |
| |
| template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> |
| struct _LIBCPP_TEMPLATE_VIS aligned_storage |
| { |
| typedef typename __find_pod<__all_types, _Align>::type _Aligner; |
| union type |
| { |
| _Aligner __align; |
| unsigned char __data[(_Len + _Align - 1)/_Align * _Align]; |
| }; |
| }; |
| |
| #if _LIBCPP_STD_VER > 11 |
| template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> |
| using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; |
| #endif |
| |
| #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ |
| template <size_t _Len>\ |
| struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\ |
| {\ |
| struct _ALIGNAS(n) type\ |
| {\ |
| unsigned char __lx[(_Len + n - 1)/n * n];\ |
| };\ |
| } |
| |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); |
| // PE/COFF does not support alignment beyond 8192 (=0x2000) |
| #if !defined(_LIBCPP_OBJECT_FORMAT_COFF) |
| _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); |
| #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF) |
| |
| #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION |
| |
| |
| // aligned_union |
| |
| template <size_t _I0, size_t ..._In> |
| struct __static_max; |
| |
| template <size_t _I0> |
| struct __static_max<_I0> |
| { |
| static const size_t value = _I0; |
| }; |
| |
| template <size_t _I0, size_t _I1, size_t ..._In> |
| struct __static_max<_I0, _I1, _In...> |
| { |
| static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : |
| __static_max<_I1, _In...>::value; |
| }; |
| |
| template <size_t _Len, class _Type0, class ..._Types> |
| struct aligned_union |
| { |
| static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), |
| _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value; |
| static const size_t __len = __static_max<_Len, sizeof(_Type0), |
| sizeof(_Types)...>::value; |
| typedef typename aligned_storage<__len, alignment_value>::type type; |
| }; |
| |
| #if _LIBCPP_STD_VER > 11 |
| template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type; |
| #endif |
| |
| template <class _Tp> |
| struct __numeric_type |
| { |
| static void __test(...); |
| static float __test(float); |
| static double __test(char); |
| static double __test(int); |
| static double __test(unsigned); |
| static double __test(long); |
| static double __test(unsigned long); |
| static double __test(long long); |
| static double __test(unsigned long long); |
| static double __test(double); |
| static long double __test(long double); |
| |
| typedef decltype(__test(declval<_Tp>())) type; |
| static const bool value = _IsNotSame<type, void>::value; |
| }; |
| |
| template <> |
| struct __numeric_type<void> |
| { |
| static const bool value = true; |
| }; |
| |
| // __promote |
| |
| template <class _A1, class _A2 = void, class _A3 = void, |
| bool = __numeric_type<_A1>::value && |
| __numeric_type<_A2>::value && |
| __numeric_type<_A3>::value> |
| class __promote_imp |
| { |
| public: |
| static const bool value = false; |
| }; |
| |
| template <class _A1, class _A2, class _A3> |
| class __promote_imp<_A1, _A2, _A3, true> |
| { |
| private: |
| typedef typename __promote_imp<_A1>::type __type1; |
| typedef typename __promote_imp<_A2>::type __type2; |
| typedef typename __promote_imp<_A3>::type __type3; |
| public: |
| typedef decltype(__type1() + __type2() + __type3()) type; |
| static const bool value = true; |
| }; |
| |
| template <class _A1, class _A2> |
| class __promote_imp<_A1, _A2, void, true> |
| { |
| private: |
| typedef typename __promote_imp<_A1>::type __type1; |
| typedef typename __promote_imp<_A2>::type __type2; |
| public: |
| typedef decltype(__type1() + __type2()) type; |
| static const bool value = true; |
| }; |
| |
| template <class _A1> |
| class __promote_imp<_A1, void, void, true> |
| { |
| public: |
| typedef typename __numeric_type<_A1>::type type; |
| static const bool value = true; |
| }; |
| |
| template <class _A1, class _A2 = void, class _A3 = void> |
| class __promote : public __promote_imp<_A1, _A2, _A3> {}; |
| |
| // make_signed / make_unsigned |
| |
| typedef |
| __type_list<signed char, |
| __type_list<signed short, |
| __type_list<signed int, |
| __type_list<signed long, |
| __type_list<signed long long, |
| #ifndef _LIBCPP_HAS_NO_INT128 |
| __type_list<__int128_t, |
| #endif |
| __nat |
| #ifndef _LIBCPP_HAS_NO_INT128 |
| > |
| #endif |
| > > > > > __signed_types; |
| |
| typedef |
| __type_list<unsigned char, |
| __type_list<unsigned short, |
| __type_list<unsigned int, |
| __type_list<unsigned long, |
| __type_list<unsigned long long, |
| #ifndef _LIBCPP_HAS_NO_INT128 |
| __type_list<__uint128_t, |
| #endif |
| __nat |
| #ifndef _LIBCPP_HAS_NO_INT128 |
| > |
| #endif |
| > > > > > __unsigned_types; |
| |
| template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first; |
| |
| template <class _Hp, class _Tp, size_t _Size> |
| struct __find_first<__type_list<_Hp, _Tp>, _Size, true> |
| { |
| typedef _LIBCPP_NODEBUG _Hp type; |
| }; |
| |
| template <class _Hp, class _Tp, size_t _Size> |
| struct __find_first<__type_list<_Hp, _Tp>, _Size, false> |
| { |
| typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type; |
| }; |
| |
| template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> |
| struct __make_signed {}; |
| |
| template <class _Tp> |
| struct __make_signed<_Tp, true> |
| { |
| typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; |
| }; |
| |
| template <> struct __make_signed<bool, true> {}; |
| template <> struct __make_signed< signed short, true> {typedef short type;}; |
| template <> struct __make_signed<unsigned short, true> {typedef short type;}; |
| template <> struct __make_signed< signed int, true> {typedef int type;}; |
| template <> struct __make_signed<unsigned int, true> {typedef int type;}; |
| template <> struct __make_signed< signed long, true> {typedef long type;}; |
| template <> struct __make_signed<unsigned long, true> {typedef long type;}; |
| template <> struct __make_signed< signed long long, true> {typedef long long type;}; |
| template <> struct __make_signed<unsigned long long, true> {typedef long long type;}; |
| #ifndef _LIBCPP_HAS_NO_INT128 |
| template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;}; |
| template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;}; |
| #endif |
| |
| template <class _Tp> |
| struct _LIBCPP_TEMPLATE_VIS make_signed |
| { |
| typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type; |
| }; |
| |
| #if _LIBCPP_STD_VER > 11 |
| template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type; |
| #endif |
| |
| template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> |
| struct __make_unsigned {}; |
| |
| template <class _Tp> |
| struct __make_unsigned<_Tp, true> |
| { |
| typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; |
| }; |
| |
| template <> struct __make_unsigned<bool, true> {}; |
| template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; |
| template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;}; |
| template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; |
| template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;}; |
| template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; |
| template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;}; |
| template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; |
| template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; |
| #ifndef _LIBCPP_HAS_NO_INT128 |
| template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;}; |
| template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;}; |
| #endif |
| |
| template <class _Tp> |
| struct _LIBCPP_TEMPLATE_VIS make_unsigned |
| { |
| typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type; |
| }; |
| |
| #if _LIBCPP_STD_VER > 11 |
| template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; |
| #endif |
| |
| #ifndef _LIBCPP_CXX03_LANG |
| template <class _Tp> |
| _LIBCPP_HIDE_FROM_ABI constexpr |
| typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept { |
| return static_cast<typename make_unsigned<_Tp>::type>(__x); |
| } |
| #endif |
| |
| #if _LIBCPP_STD_VER > 17 |
| // Let COND_RES(X, Y) be: |
| template <class _Tp, class _Up> |
| using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>()); |
| |
| template <class _Tp, class _Up, class = void> |
| struct __common_type3 {}; |
| |
| // sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..." |
| template <class _Tp, class _Up> |
| struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>> |
| { |
| using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>; |
| }; |
| |
| template <class _Tp, class _Up, class = void> |
| struct __common_type2_imp : __common_type3<_Tp, _Up> {}; |
| #else |
| template <class _Tp, class _Up, class = void> |
| struct __common_type2_imp {}; |
| #endif |
| |
| // sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..." |
| template <class _Tp, class _Up> |
| struct __common_type2_imp<_Tp, _Up, |
| typename __void_t<decltype( |
| true ? declval<_Tp>() : declval<_Up>() |
| )>::type> |
| { |
| typedef _LIBCPP_NODEBUG typename decay<decltype( |
| true ? declval<_Tp>() : declval<_Up>() |
| )>::type type; |
| }; |
| |
| template <class, class = void> |
| struct __common_type_impl {}; |
| |
| // Clang provides variadic templates in C++03 as an extension. |
| #if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__) |
| # define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__ |
| template <class... _Tp> |
| struct __common_types; |
| template <class... _Tp> |
| struct _LIBCPP_TEMPLATE_VIS common_type; |
| #else |
| # define _LIBCPP_OPTIONAL_PACK(...) |
| struct __no_arg; |
| template <class _Tp, class _Up, class = __no_arg> |
| struct __common_types; |
| template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg, |
| class _Unused = __no_arg> |
| struct common_type { |
| static_assert(sizeof(_Unused) == 0, |
| "common_type accepts at most 3 arguments in C++03"); |
| }; |
| #endif // _LIBCPP_CXX03_LANG |
| |
| template <class _Tp, class _Up> |
| struct __common_type_impl< |
| __common_types<_Tp, _Up>, |
| typename __void_t<typename common_type<_Tp, _Up>::type>::type> |
| { |
| typedef typename common_type<_Tp, _Up>::type type; |
| }; |
| |
| template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> |
| struct __common_type_impl< |
| __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>, |
| typename __void_t<typename common_type<_Tp, _Up>::type>::type> |
| : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type, |
| _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > { |
| }; |
| |
| // bullet 1 - sizeof...(Tp) == 0 |
| |
| template <> |
| struct _LIBCPP_TEMPLATE_VIS common_type<> {}; |
| |
| // bullet 2 - sizeof...(Tp) == 1 |
| |
| template <class _Tp> |
| struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> |
| : public common_type<_Tp, _Tp> {}; |
| |
| // bullet 3 - sizeof...(Tp) == 2 |
| |
| // sub-bullet 1 - "If is_same_v<T1, D1> is false or ..." |
| template <class _Tp, class _Up> |
| struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> |
| : conditional< |
| _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value, |
| __common_type2_imp<_Tp, _Up>, |
| common_type<typename decay<_Tp>::type, typename decay<_Up>::type> |
| >::type |
| {}; |
| |
| // bullet 4 - sizeof...(Tp) > 2 |
| |
| template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> |
| struct _LIBCPP_TEMPLATE_VIS |
| common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> |
| : __common_type_impl< |
| __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {}; |
| |
| #undef _LIBCPP_OPTIONAL_PACK |
| |
| #if _LIBCPP_STD_VER > 11 |
| template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type; |
| #endif |
| |
| #if _LIBCPP_STD_VER > 11 |
| // Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's |
| // top-level cv-qualifiers. |
| template <class _From, class _To> |
| struct __copy_cv |
| { |
| using type = _To; |
| }; |
| |
| template <class _From, class _To> |
| struct __copy_cv<const _From, _To> |
| { |
| using type = add_const_t<_To>; |
| }; |
| |
| template <class _From, class _To> |
| struct __copy_cv<volatile _From, _To> |
| { |
| using type = add_volatile_t<_To>; |
| }; |
| |
| template <class _From, class _To> |
| struct __copy_cv<const volatile _From, _To> |
| { |
| using type = add_cv_t<_To>; |
| }; |
| |
| template <class _From, class _To> |
| using __copy_cv_t = typename __copy_cv<_From, _To>::type; |
| |
| template <class _From, class _To> |
| struct __copy_cvref |
| { |
| using type = __copy_cv_t<_From, _To>; |
| }; |
| |
| template <class _From, class _To> |
| struct __copy_cvref<_From&, _To> |
| { |
| using type = add_lvalue_reference_t<__copy_cv_t<_From, _To>>; |
| }; |
| |
| template <class _From, class _To> |
| struct __copy_cvref<_From&&, _To> |
| { |
| using type = add_rvalue_reference_t<__copy_cv_t<_From, _To>>; |
| }; |
| |
| template <class _From, class _To> |
| using __copy_cvref_t = typename __copy_cvref<_From, _To>::type; |
| |
| #endif // _LIBCPP_STD_VER > 11 |
| |
| // common_reference |
| #if _LIBCPP_STD_VER > 17 |
| // Let COND_RES(X, Y) be: |
| template <class _Xp, class _Yp> |
| using __cond_res = |
| decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()()); |
| |
| // Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U` |
| // with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type |
| // `U`. |
| // [Note: `XREF(A)` is `__xref<A>::template __apply`] |
| template <class _Tp> |
| struct __xref { |
| template<class _Up> |
| using __apply = __copy_cvref_t<_Tp, _Up>; |
| }; |
| |
| // Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>, |
| // and let COMMON-REF(A, B) be: |
| template<class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp = remove_reference_t<_Bp>> |
| struct __common_ref; |
| |
| template<class _Xp, class _Yp> |
| using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type; |
| |
| template<class _Xp, class _Yp> |
| using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>; |
| |
| |
| // If A and B are both lvalue reference types, COMMON-REF(A, B) is |
| // COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type. |
| template<class _Ap, class _Bp, class _Xp, class _Yp> |
| requires requires { typename __cv_cond_res<_Xp, _Yp>; } && is_reference_v<__cv_cond_res<_Xp, _Yp>> |
| struct __common_ref<_Ap&, _Bp&, _Xp, _Yp> |
| { |
| using __type = __cv_cond_res<_Xp, _Yp>; |
| }; |
| |
| // Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ... |
| template <class _Xp, class _Yp> |
| using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&; |
| |
| |
| // .... If A and B are both rvalue reference types, C is well-formed, and |
| // is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C. |
| template<class _Ap, class _Bp, class _Xp, class _Yp> |
| requires |
| requires { typename __common_ref_C<_Xp, _Yp>; } && |
| is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> && |
| is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>> |
| struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp> |
| { |
| using __type = __common_ref_C<_Xp, _Yp>; |
| }; |
| |
| // Otherwise, let D be COMMON-REF(const X&, Y&). ... |
| template <class _Tp, class _Up> |
| using __common_ref_D = __common_ref_t<const _Tp&, _Up&>; |
| |
| // ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and |
| // is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D. |
| template<class _Ap, class _Bp, class _Xp, class _Yp> |
| requires requires { typename __common_ref_D<_Xp, _Yp>; } && |
| is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>> |
| struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp> |
| { |
| using __type = __common_ref_D<_Xp, _Yp>; |
| }; |
| |
| // Otherwise, if A is an lvalue reference and B is an rvalue reference, then |
| // COMMON-REF(A, B) is COMMON-REF(B, A). |
| template<class _Ap, class _Bp, class _Xp, class _Yp> |
| struct __common_ref<_Ap&, _Bp&&, _Xp, _Yp> : __common_ref<_Bp&&, _Ap&> {}; |
| |
| // Otherwise, COMMON-REF(A, B) is ill-formed. |
| template<class _Ap, class _Bp, class _Xp, class _Yp> |
| struct __common_ref {}; |
| |
| // Note C: For the common_reference trait applied to a parameter pack [...] |
| |
| template <class...> |
| struct common_reference; |
| |
| template <class... _Types> |
| using common_reference_t = typename common_reference<_Types...>::type; |
| |
| // bullet 1 - sizeof...(T) == 0 |
| template<> |
| struct common_reference<> {}; |
| |
| // bullet 2 - sizeof...(T) == 1 |
| template <class _Tp> |
| struct common_reference<_Tp> |
| { |
| using type = _Tp; |
| }; |
| |
| // bullet 3 - sizeof...(T) == 2 |
| template <class _Tp, class _Up> struct __common_reference_sub_bullet3; |
| template <class _Tp, class _Up> struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> {}; |
| template <class _Tp, class _Up> struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {}; |
| |
| // sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then |
| // the member typedef `type` denotes that type. |
| template <class _Tp, class _Up> struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {}; |
| |
| template <class _Tp, class _Up> |
| requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; } |
| struct __common_reference_sub_bullet1<_Tp, _Up> |
| { |
| using type = __common_ref_t<_Tp, _Up>; |
| }; |
| |
| // sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type |
| // is well-formed, then the member typedef `type` denotes that type. |
| template <class, class, template <class> class, template <class> class> struct basic_common_reference {}; |
| |
| template <class _Tp, class _Up> |
| using __basic_common_reference_t = typename basic_common_reference< |
| remove_cvref_t<_Tp>, remove_cvref_t<_Up>, |
| __xref<_Tp>::template __apply, __xref<_Up>::template __apply>::type; |
| |
| template <class _Tp, class _Up> |
| requires requires { typename __basic_common_reference_t<_Tp, _Up>; } |
| struct __common_reference_sub_bullet2<_Tp, _Up> |
| { |
| using type = __basic_common_reference_t<_Tp, _Up>; |
| }; |
| |
| // sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed, |
| // then the member typedef `type` denotes that type. |
| template <class _Tp, class _Up> |
| requires requires { typename __cond_res<_Tp, _Up>; } |
| struct __common_reference_sub_bullet3<_Tp, _Up> |
| { |
| using type = __cond_res<_Tp, _Up>; |
| }; |
| |
| |
| // sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed, |
| // then the member typedef `type` denotes that type. |
| // - Otherwise, there shall be no member `type`. |
| template <class _Tp, class _Up> struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {}; |
| |
| // bullet 4 - If there is such a type `C`, the member typedef type shall denote the same type, if |
| // any, as `common_reference_t<C, Rest...>`. |
| template <class _Tp, class _Up, class _Vp, class... _Rest> |
| requires requires { typename common_reference_t<_Tp, _Up>; } |
| struct common_reference<_Tp, _Up, _Vp, _Rest...> |
| : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...> |
| {}; |
| |
| // bullet 5 - Otherwise, there shall be no member `type`. |
| template <class...> struct common_reference {}; |
| |
| #endif // _LIBCPP_STD_VER > 17 |
| |
| #ifndef _LIBCPP_CXX03_LANG |
| // First of all, we can't implement this check in C++03 mode because the {} |
| // default initialization syntax isn't valid. |
| // Second, we implement the trait in a funny manner with two defaulted template |
| // arguments to workaround Clang's PR43454. |
| template <class _Tp> |
| void __test_implicit_default_constructible(_Tp); |
| |
| template <class _Tp, class = void, class = typename is_default_constructible<_Tp>::type> |
| struct __is_implicitly_default_constructible |
| : false_type |
| { }; |
| |
| template <class _Tp> |
| struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true_type> |
| : true_type |
| { }; |
| |
| template <class _Tp> |
| struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false_type> |
| : false_type |
| { }; |
| #endif // !C++03 |
| |
| // result_of |
| |
| #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) |
| template <class _Callable> class _LIBCPP_DEPRECATED_IN_CXX17 result_of; |
| |
| #ifndef _LIBCPP_CXX03_LANG |
| |
| template <class _Fp, class ..._Args> |
| class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> |
| : public __invoke_of<_Fp, _Args...> |
| { |
| }; |
| |
| #else // C++03 |
| |
| template <class _Fn, bool, bool> |
| class __result_of |
| { |
| }; |
| |
| template <class _Fn, class ..._Args> |
| class __result_of<_Fn(_Args...), true, false> |
| { |
| public: |
| typedef decltype(declval<_Fn>()(declval<_Args>()...)) type; |
| }; |
| |
| template <class _MP, class _Tp, bool _IsMemberFunctionPtr> |
| struct __result_of_mp; |
| |
| // member function pointer |
| |
| template <class _MP, class _Tp> |
| struct __result_of_mp<_MP, _Tp, true> |
| { |
| using type = typename __member_pointer_traits<_MP>::_ReturnType; |
| }; |
| |
| // member data pointer |
| |
| template <class _MP, class _Tp, bool> |
| struct __result_of_mdp; |
| |
| template <class _Rp, class _Class, class _Tp> |
| struct __result_of_mdp<_Rp _Class::*, _Tp, false> |
| { |
| using type = typename __apply_cv<decltype(*declval<_Tp>()), _Rp>::type&; |
| }; |
| |
| template <class _Rp, class _Class, class _Tp> |
| struct __result_of_mdp<_Rp _Class::*, _Tp, true> |
| { |
| using type = typename __apply_cv<_Tp, _Rp>::type&; |
| }; |
| |
| template <class _Rp, class _Class, class _Tp> |
| struct __result_of_mp<_Rp _Class::*, _Tp, false> |
| : public __result_of_mdp<_Rp _Class::*, _Tp, |
| is_base_of<_Class, typename remove_reference<_Tp>::type>::value> |
| { |
| }; |
| |
| template <class _Fn, class _Tp> |
| class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer |
| : public __result_of_mp<typename remove_reference<_Fn>::type, |
| _Tp, |
| is_member_function_pointer<typename remove_reference<_Fn>::type>::value> |
| { |
| }; |
| |
| template <class _Fn, class _Tp, class ..._Args> |
| class __result_of<_Fn(_Tp, _Args...), false, true> // _Fn must be member pointer |
| : public __result_of_mp<typename remove_reference<_Fn>::type, |
| _Tp, |
| is_member_function_pointer<typename remove_reference<_Fn>::type>::value> |
| { |
| }; |
| |
| template <class _Fn, class ..._Args> |
| class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_Args...)> |
| : public __result_of<_Fn(_Args...), |
| is_class<typename remove_reference<_Fn>::type>::value || |
| is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, |
| is_member_pointer<typename remove_reference<_Fn>::type>::value |
| > |
| { |
| }; |
| |
| #endif // C++03 |
| |
| #if _LIBCPP_STD_VER > 11 |
| template <class _Tp> using result_of_t _LIBCPP_DEPRECATED_IN_CXX17 = typename result_of<_Tp>::type; |
| #endif // _LIBCPP_STD_VER > 11 |
| #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) |
| |
| // __swappable |
| |
| template <class _Tp> struct __is_swappable; |
| template <class _Tp> struct __is_nothrow_swappable; |
| |
| |
| #ifndef _LIBCPP_CXX03_LANG |
| template <class _Tp> |
| using __swap_result_t = typename enable_if<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>::type; |
| #else |
| template <class> |
| using __swap_result_t = void; |
| #endif |
| |
| template <class _Tp> |
| inline _LIBCPP_INLINE_VISIBILITY |
| _LIBCPP_CONSTEXPR_AFTER_CXX17 __swap_result_t<_Tp> |
| swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value && |
| is_nothrow_move_assignable<_Tp>::value); |
| |
| template<class _Tp, size_t _Np> |
| inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| typename enable_if< |
| __is_swappable<_Tp>::value |
| >::type |
| swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value); |
| |
| namespace __detail |
| { |
| // ALL generic swap overloads MUST already have a declaration available at this point. |
| |
| template <class _Tp, class _Up = _Tp, |
| bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value> |
| struct __swappable_with |
| { |
| template <class _LHS, class _RHS> |
| static decltype(swap(declval<_LHS>(), declval<_RHS>())) |
| __test_swap(int); |
| template <class, class> |
| static __nat __test_swap(long); |
| |
| // Extra parens are needed for the C++03 definition of decltype. |
| typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1; |
| typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2; |
| |
| static const bool value = _IsNotSame<__swap1, __nat>::value |
| && _IsNotSame<__swap2, __nat>::value; |
| }; |
| |
| template <class _Tp, class _Up> |
| struct __swappable_with<_Tp, _Up, false> : false_type {}; |
| |
| template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value> |
| struct __nothrow_swappable_with { |
| static const bool value = |
| #ifndef _LIBCPP_HAS_NO_NOEXCEPT |
| noexcept(swap(declval<_Tp>(), declval<_Up>())) |
| && noexcept(swap(declval<_Up>(), declval<_Tp>())); |
| #else |
| false; |
| #endif |
| }; |
| |
| template <class _Tp, class _Up> |
| struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {}; |
| |
| } // namespace __detail |
| |
| template <class _Tp> |
| struct __is_swappable |
| : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value> |
| { |
| }; |
| |
| template <class _Tp> |
| struct __is_nothrow_swappable |
| : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value> |
| { |
| }; |
| |
| #if _LIBCPP_STD_VER > 14 |
| |
| template <class _Tp, class _Up> |
| struct _LIBCPP_TEMPLATE_VIS is_swappable_with |
| : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value> |
| { |
| }; |
| |
| template <class _Tp> |
| struct _LIBCPP_TEMPLATE_VIS is_swappable |
| : public conditional< |
| __is_referenceable<_Tp>::value, |
| is_swappable_with< |
| typename add_lvalue_reference<_Tp>::type, |
| typename add_lvalue_reference<_Tp>::type>, |
| false_type |
| >::type |
| { |
| }; |
| |
| template <class _Tp, class _Up> |
| struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with |
| : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value> |
| { |
| }; |
| |
| template <class _Tp> |
| struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable |
| : public conditional< |
| __is_referenceable<_Tp>::value, |
| is_nothrow_swappable_with< |
| typename add_lvalue_reference<_Tp>::type, |
| typename add_lvalue_reference<_Tp>::type>, |
| false_type |
| >::type |
| { |
| }; |
| |
| template <class _Tp, class _Up> |
| inline constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value; |
| |
| template <class _Tp> |
| inline constexpr bool is_swappable_v = is_swappable<_Tp>::value; |
| |
| template <class _Tp, class _Up> |
| inline constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value; |
| |
| template <class _Tp> |
| inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value; |
| |
| #endif // _LIBCPP_STD_VER > 14 |
| |
| template <class _Tp, bool = is_enum<_Tp>::value> |
| struct __sfinae_underlying_type |
| { |
| typedef typename underlying_type<_Tp>::type type; |
| typedef decltype(((type)1) + 0) __promoted_type; |
| }; |
| |
| template <class _Tp> |
| struct __sfinae_underlying_type<_Tp, false> {}; |
| |
| inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| int __convert_to_integral(int __val) { return __val; } |
| |
| inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| unsigned __convert_to_integral(unsigned __val) { return __val; } |
| |
| inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| long __convert_to_integral(long __val) { return __val; } |
| |
| inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| unsigned long __convert_to_integral(unsigned long __val) { return __val; } |
| |
| inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| long long __convert_to_integral(long long __val) { return __val; } |
| |
| inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| unsigned long long __convert_to_integral(unsigned long long __val) {return __val; } |
| |
| template<typename _Fp> |
| inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| typename enable_if<is_floating_point<_Fp>::value, long long>::type |
| __convert_to_integral(_Fp __val) { return __val; } |
| |
| #ifndef _LIBCPP_HAS_NO_INT128 |
| inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| __int128_t __convert_to_integral(__int128_t __val) { return __val; } |
| |
| inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| __uint128_t __convert_to_integral(__uint128_t __val) { return __val; } |
| #endif |
| |
| template <class _Tp> |
| inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| typename __sfinae_underlying_type<_Tp>::__promoted_type |
| __convert_to_integral(_Tp __val) { return __val; } |
| |
| // These traits are used in __tree and __hash_table |
| struct __extract_key_fail_tag {}; |
| struct __extract_key_self_tag {}; |
| struct __extract_key_first_tag {}; |
| |
| template <class _ValTy, class _Key, |
| class _RawValTy = typename __unconstref<_ValTy>::type> |
| struct __can_extract_key |
| : conditional<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag, |
| __extract_key_fail_tag>::type {}; |
| |
| template <class _Pair, class _Key, class _First, class _Second> |
| struct __can_extract_key<_Pair, _Key, pair<_First, _Second> > |
| : conditional<_IsSame<typename remove_const<_First>::type, _Key>::value, |
| __extract_key_first_tag, __extract_key_fail_tag>::type {}; |
| |
| // __can_extract_map_key uses true_type/false_type instead of the tags. |
| // It returns true if _Key != _ContainerValueTy (the container is a map not a set) |
| // and _ValTy == _Key. |
| template <class _ValTy, class _Key, class _ContainerValueTy, |
| class _RawValTy = typename __unconstref<_ValTy>::type> |
| struct __can_extract_map_key |
| : integral_constant<bool, _IsSame<_RawValTy, _Key>::value> {}; |
| |
| // This specialization returns __extract_key_fail_tag for non-map containers |
| // because _Key == _ContainerValueTy |
| template <class _ValTy, class _Key, class _RawValTy> |
| struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy> |
| : false_type {}; |
| |
| template <class _CharT> |
| using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >; |
| |
| template<class _Tp> |
| using __make_const_lvalue_ref = const typename remove_reference<_Tp>::type&; |
| |
| #if _LIBCPP_STD_VER > 17 |
| template<bool _Const, class _Tp> |
| using __maybe_const = conditional_t<_Const, const _Tp, _Tp>; |
| #endif // _LIBCPP_STD_VER > 17 |
| |
| _LIBCPP_END_NAMESPACE_STD |
| |
| #endif // _LIBCPP_TYPE_TRAITS |