Decouple swap from std (#1211)

This allows you to implement your own swap function without it having to
be part of the std namespace. std::swap is still used if it's available.
This commit is contained in:
Jōshin 2024-06-10 03:40:17 -07:00 committed by GitHub
parent 0a92c78035
commit 32643e9fa7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -118,8 +118,9 @@ class optional
void swap(optional& other) noexcept
{
using std::swap;
if (present_ && other.present_) {
std::swap(value_, other.value_);
swap(value_, other.value_);
} else if (present_) {
other.emplace(std::move(value_));
reset();