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

This commit is contained in:
Josh Holtrop 2026-02-25 08:16:33 -05:00
parent b87fbc0d76
commit 8d0243dcde
2 changed files with 9 additions and 0 deletions

View File

@ -246,6 +246,12 @@ namespace std
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>

View File

@ -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()