MCPcopy Create free account
hub / github.com/davisking/dlib / swap

Method swap

dlib/optional.h:594–615  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

592 }
593
594 void swap(optional& rhs) noexcept(std::is_nothrow_move_constructible<T>::value &&
595 dlib::is_nothrow_swappable<T>::value)
596 {
597 using std::swap;
598
599 if (*this && rhs)
600 {
601 swap(**this, *rhs);
602 }
603
604 else if (*this && !rhs)
605 {
606 rhs = std::move(**this);
607 reset();
608 }
609
610 else if (!*this && rhs)
611 {
612 *this = std::move(*rhs);
613 rhs.reset();
614 }
615 }
616
617 constexpr const T* operator->() const noexcept { return &this->val; }
618 constexpr T* operator->() noexcept { return &this->val; }

Callers 1

swapFunction · 0.45

Calls 3

moveFunction · 0.85
swapFunction · 0.70
resetMethod · 0.45

Tested by

no test coverage detected