Add free std::swap() specialization function for rcp

This commit is contained in:
josh committed 2026-02-25 08:16:33 -05:00
1 parent b87fbc0d76
commit 8d0243dcde
2 files changed
+9

No files matched your search

+6
View File
@@ -246,6 +246,12 @@ namespace std
return hash<const void *>()(static_cast<const void *>(p.get_raw())); return hash<const void *>()(static_cast<const void *>(p.get_raw()));
} }
}; };
template <typename T>
void swap(rcp<T> & a, rcp<T> & b) noexcept
{
a.swap(b);
}
} }
template <typename T, typename U> template <typename T, typename U>
+3
View File
@@ -376,6 +376,9 @@ void test_swap()
a.swap(b); a.swap(b);
assert(a->x == 3); assert(a->x == 3);
assert(b->x == 1); assert(b->x == 1);
std::swap(a, b);
assert(a->x == 1);
assert(b->x == 3);
} }
void test_hash() void test_hash()