[committed] libstdc++: Adjust flat_set::swap swapping order

Patrick Palka ppalka@redhat.com
Fri May 29 19:19:55 GMT 2026


Tested on x86_64-pc-linux-gnu, pushed to trunk as obvious (will also
backport to 16 alongside r17-908).

-- >8 --

In r17-908 I accidentally made us swap the comparator first, but we
decided that the container should be swapped first.

libstdc++-v3/ChangeLog:

	* include/std/flat_set (_Flat_set_base::swap): Swap _M_cont
	first.
---
 libstdc++-v3/include/std/flat_set | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/flat_set b/libstdc++-v3/include/std/flat_set
index 2f204cc08bf9..31dce48bbe0a 100644
--- a/libstdc++-v3/include/std/flat_set
+++ b/libstdc++-v3/include/std/flat_set
@@ -680,8 +680,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	auto __guard = _M_make_clear_guard();
 	auto __guard_y = _ClearGuard{__y._M_cont};
-	ranges::swap(_M_comp, __y._M_comp);
 	ranges::swap(_M_cont, __y._M_cont);
+	ranges::swap(_M_comp, __y._M_comp);
 	__guard._M_disable();
 	__guard_y._M_disable();
       }
-- 
2.54.0.rc1.54.g60f07c4f5c



More information about the Libstdc++ mailing list