From a8e168e0c18bb7ac57361500cd98601160a107cc Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Tue, 25 Mar 2025 15:58:24 +0100 Subject: [PATCH] [libc++][NFC] Replace structs with variable templates in <__memory/allocator_traits.h> (#129237) Variable templates are a bit easier on the compiler and improve the readability of the code. --- libcxx/include/__flat_map/flat_map.h | 1 + libcxx/include/__memory/allocator_traits.h | 119 ++++++++---------- .../__memory/uninitialized_algorithms.h | 24 ++-- libcxx/include/__vector/container_traits.h | 2 +- libcxx/include/deque | 2 +- 5 files changed, 64 insertions(+), 84 deletions(-) diff --git a/libcxx/include/__flat_map/flat_map.h b/libcxx/include/__flat_map/flat_map.h index a0594ed9dc41..f5abfd098528 100644 --- a/libcxx/include/__flat_map/flat_map.h +++ b/libcxx/include/__flat_map/flat_map.h @@ -33,6 +33,7 @@ #include <__functional/invoke.h> #include <__functional/is_transparent.h> #include <__functional/operations.h> +#include <__fwd/memory.h> #include <__fwd/vector.h> #include <__iterator/concepts.h> #include <__iterator/distance.h> diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h index 3180f5e3d542..7e964b764701 100644 --- a/libcxx/include/__memory/allocator_traits.h +++ b/libcxx/include/__memory/allocator_traits.h @@ -151,13 +151,13 @@ using __is_always_equal _LIBCPP_NODEBUG = // __allocator_traits_rebind template -struct __has_rebind_other : false_type {}; +inline const bool __has_rebind_other_v = false; template -struct __has_rebind_other<_Tp, _Up, __void_t::other> > : true_type {}; +inline const bool __has_rebind_other_v<_Tp, _Up, __void_t::other> > = true; -template ::value> +template > struct __allocator_traits_rebind { - static_assert(__has_rebind_other<_Tp, _Up>::value, "This allocator has to implement rebind"); + static_assert(__has_rebind_other_v<_Tp, _Up>, "This allocator has to implement rebind"); using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other; }; template