From 52fe3cca457f917746723d79a69c39216c36f24e Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Mon, 23 Jun 2025 12:11:14 +0200 Subject: [PATCH] [libc++] Remove a bunch of declarations from __tree and simplif __is_tree_value_type --- libcxx/include/__tree | 41 ++++--------------- .../include/__type_traits/is_specialization.h | 8 +--- 2 files changed, 10 insertions(+), 39 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 3dd5ae585e1db..6dadd0915c984 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -27,15 +27,13 @@ #include <__type_traits/copy_cvref.h> #include <__type_traits/enable_if.h> #include <__type_traits/invoke.h> -#include <__type_traits/is_const.h> #include <__type_traits/is_constructible.h> #include <__type_traits/is_nothrow_assignable.h> #include <__type_traits/is_nothrow_constructible.h> #include <__type_traits/is_same.h> +#include <__type_traits/is_specialization.h> #include <__type_traits/is_swappable.h> #include <__type_traits/remove_const.h> -#include <__type_traits/remove_const_ref.h> -#include <__type_traits/remove_cvref.h> #include <__utility/forward.h> #include <__utility/move.h> #include <__utility/pair.h> @@ -51,13 +49,6 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD -template -class __tree; -template -class __tree_iterator; -template -class __tree_const_iterator; - template class __tree_end_node; template @@ -68,13 +59,6 @@ class __tree_node; template struct __value_type; -template -class __map_node_destructor; -template -class __map_iterator; -template -class __map_const_iterator; - /* _NodePtr algorithms @@ -492,16 +476,7 @@ _LIBCPP_HIDE_FROM_ABI void __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEP // node traits template -struct __is_tree_value_type_imp : false_type {}; - -template -struct __is_tree_value_type_imp<__value_type<_Key, _Value> > : true_type {}; - -template -struct __is_tree_value_type : false_type {}; - -template -struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__remove_cvref_t<_One> > {}; +inline const bool __is_tree_value_type_v = __is_specialization_v<_Tp, __value_type>; template struct __get_tree_key_type { @@ -974,23 +949,23 @@ public: return __emplace_hint_unique_key_args(__p, __x.first, std::forward<_Pp>(__x)).first; } - template ::value, int> = 0> + template , int> = 0> _LIBCPP_HIDE_FROM_ABI void __insert_unique_from_orphaned_node(const_iterator __p, __get_node_value_type_t<_Tp>&& __value) { __emplace_hint_unique(__p, const_cast(__value.first), std::move(__value.second)); } - template ::value, int> = 0> + template , int> = 0> _LIBCPP_HIDE_FROM_ABI void __insert_unique_from_orphaned_node(const_iterator __p, _Tp&& __value) { __emplace_hint_unique(__p, std::move(__value)); } - template ::value, int> = 0> + template , int> = 0> _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(const_iterator __p, value_type&& __value) { __emplace_hint_multi(__p, const_cast(__value.first), std::move(__value.second)); } - template ::value, int> = 0> + template , int> = 0> _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(const_iterator __p, _Tp&& __value) { __emplace_hint_multi(__p, std::move(__value)); } @@ -1137,7 +1112,7 @@ private: } _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {} - template ::value, int> = 0> + template , int> = 0> _LIBCPP_HIDE_FROM_ABI static void __assign_value(__get_node_value_type_t& __lhs, _From&& __rhs) { using __key_type = __remove_const_t; @@ -1147,7 +1122,7 @@ private: __lhs.second = std::forward<_From>(__rhs).second; } - template ::value, int> = 0> + template , int> = 0> _LIBCPP_HIDE_FROM_ABI static void __assign_value(_To& __lhs, _From&& __rhs) { __lhs = std::forward<_From>(__rhs); } diff --git a/libcxx/include/__type_traits/is_specialization.h b/libcxx/include/__type_traits/is_specialization.h index 9b75636b1a511..f14ab93c3c7dc 100644 --- a/libcxx/include/__type_traits/is_specialization.h +++ b/libcxx/include/__type_traits/is_specialization.h @@ -30,15 +30,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 17 - template class _Template> -inline constexpr bool __is_specialization_v = false; // true if and only if _Tp is a specialization of _Template +inline const bool __is_specialization_v = false; // true if and only if _Tp is a specialization of _Template template