Decouple swap from std

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-09 19:59:31 -07:00
parent 0a92c78035
commit a6f1807d98
No known key found for this signature in database

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