mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
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:
parent
0a92c78035
commit
32643e9fa7
1 changed files with 2 additions and 1 deletions
|
@ -118,8 +118,9 @@ class optional
|
||||||
|
|
||||||
void swap(optional& other) noexcept
|
void swap(optional& other) noexcept
|
||||||
{
|
{
|
||||||
|
using std::swap;
|
||||||
if (present_ && other.present_) {
|
if (present_ && other.present_) {
|
||||||
std::swap(value_, other.value_);
|
swap(value_, other.value_);
|
||||||
} else if (present_) {
|
} else if (present_) {
|
||||||
other.emplace(std::move(value_));
|
other.emplace(std::move(value_));
|
||||||
reset();
|
reset();
|
||||||
|
|
Loading…
Reference in a new issue