From 8d0243dcdee69a3f57118497430cc9936fac0777 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 25 Feb 2026 08:16:33 -0500 Subject: [PATCH] Add free std::swap() specialization function for rcp --- include/rcp.h | 6 ++++++ tests.cpp | 3 +++ 2 files changed, 9 insertions(+) diff --git a/include/rcp.h b/include/rcp.h index d49a156..9d33a6a 100644 --- a/include/rcp.h +++ b/include/rcp.h @@ -246,6 +246,12 @@ namespace std return hash()(static_cast(p.get_raw())); } }; + + template + void swap(rcp & a, rcp & b) noexcept + { + a.swap(b); + } } template diff --git a/tests.cpp b/tests.cpp index 6bd55a3..1ca8d0c 100644 --- a/tests.cpp +++ b/tests.cpp @@ -376,6 +376,9 @@ void test_swap() a.swap(b); assert(a->x == 3); assert(b->x == 1); + std::swap(a, b); + assert(a->x == 1); + assert(b->x == 3); } void test_hash()