[libcxx-commits] [libcxx] [libc++][NFC] Don't explicitly provide propagate_on_container_swap when calling __swap_allocator (PR #105980)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Sun Aug 25 04:05:38 PDT 2024


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/105980

`__swap_allocator` does this automatically when not providing it explicitly, so this is just more code without any benefit.


>From e1e930ce80648d5b68b4f0bcbe36e3cb876ea201 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Sun, 25 Aug 2024 13:04:47 +0200
Subject: [PATCH] [libc++][NFC] Don't explicitly provide
 propagate_on_container_swap when calling __swap_allocator

---
 libcxx/include/forward_list | 3 +--
 libcxx/include/vector       | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index b14d2cb6c78036..b8e3d05588f96e 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -620,8 +620,7 @@ inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
     _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)
 #endif
 {
-  std::__swap_allocator(
-      __alloc(), __x.__alloc(), integral_constant<bool, __node_traits::propagate_on_container_swap::value>());
+  std::__swap_allocator(__alloc(), __x.__alloc());
   using std::swap;
   swap(__before_begin()->__next_, __x.__before_begin()->__next_);
 }
diff --git a/libcxx/include/vector b/libcxx/include/vector
index 3aa23d8fc1e243..a858f458f44308 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -1821,8 +1821,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::swap(vector& __x)
   std::swap(this->__begin_, __x.__begin_);
   std::swap(this->__end_, __x.__end_);
   std::swap(this->__end_cap(), __x.__end_cap());
-  std::__swap_allocator(
-      this->__alloc(), __x.__alloc(), integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
+  std::__swap_allocator(this->__alloc(), __x.__alloc());
 }
 
 template <class _Tp, class _Allocator>
@@ -2820,8 +2819,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::swap(vector& __x)
   std::swap(this->__begin_, __x.__begin_);
   std::swap(this->__size_, __x.__size_);
   std::swap(this->__cap(), __x.__cap());
-  std::__swap_allocator(
-      this->__alloc(), __x.__alloc(), integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>());
+  std::__swap_allocator(this->__alloc(), __x.__alloc());
 }
 
 template <class _Allocator>



More information about the libcxx-commits mailing list