MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / swap

Function swap

extlibs/sol3/include/sol/sol.hpp:4697–4712  ·  view source on GitHub ↗

Swaps this optional with the other. If neither optionals have a value, nothing happens. If both have a value, the values are swapped. If one has a value, it is moved to the other and the movee is left valueless.

Source from the content-addressed store, hash-verified

4695 /// If one has a value, it is moved to the other and the movee is left
4696 /// valueless.
4697 void swap(optional& rhs) noexcept(std::is_nothrow_move_constructible<T>::value&& detail::is_nothrow_swappable<T>::value) {
4698 if (has_value()) {
4699 if (rhs.has_value()) {
4700 using std::swap;
4701 swap(**this, *rhs);
4702 }
4703 else {
4704 new (std::addressof(rhs.m_value)) T(std::move(this->m_value));
4705 this->m_value.T::~T();
4706 }
4707 }
4708 else if (rhs.has_value()) {
4709 new (std::addressof(this->m_value)) T(std::move(rhs.m_value));
4710 rhs.m_value.T::~T();
4711 }
4712 }
4713
4714 /// \returns a pointer to the stored value
4715 /// \requires a value is stored

Callers 4

sol.hppFile · 0.70
swapMethod · 0.70
swapMethod · 0.50
fallback_uintptrMethod · 0.50

Calls 3

has_valueFunction · 0.85
has_valueMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected