std::experi...tional::swap(3)
π std::experi...tional::swap(3) β from the C++ Standard Libary π
okay so bestie, welcome to the std::experi...tional::swap(3) page. Manual name? C++ Standard Libary (yes, thatβs spelled exactly like that). This is the std::experimental::optional::swap glow-up, and weβre gonna get through every little detail together π«Άβ¨
πΈ NAME πΈ
std::experimental::optional::swap - std::experimental::optional::swap β okay so thatβs the whole NAME line, bestie; same name twice, no notes π
π¦ Synopsis π¦
void swap( optional& other ) noexcept(/* see below */); (library
fundamentals TS)
Swaps the contents with those of other. Thatβs the whole main-character move.
- If neither
*thisnorothercontain a value, the function has no effect. literally nothing happens, and thatβs valid π - If only one of
*thisandothercontains a value (letβs call this objectinand the otherun), the contained value ofunis direct-initialized fromstd::move(*in), followed by destruction of the contained value ofinas if byin.val->T::~T(). After this call,indoes not contain a value, anduncontains a value. slay, the value moved houses π β¨ - If both
*thisandothercontain values, the contained values are exchanged by callingusing std::swap; swap(**this, *other). TheTlvalues must satisfySwappable. no cap, thatβs the requirement.
π Parameters π
otherβ the optional object to exchange the contents with.
β Return value β
(none) β nothing is returned, bestie.
π₯ Exceptions π₯
noexcept specification:
noexcept(std::is_nothrow_move_constructible<T>::value &&
noexcept(swap(std::declval<T&>(), std::declval<T&>())))
In the case of a thrown exception, the states of the contained values of *this and other are determined by the exception safety guarantees of swap of type T or T's move constructor, whichever is called. For both *this and other, if the object contained a value, it is left containing a value, and the other way round. important caveat, bestie β read it twice if you need π
π See also π
std::swap(std::experimental::optional)β specializes thestd::swapalgorithm (function).
π·οΈ Categories π·οΈ
- Noindexed pages
- conditionally noexcept
mwah π β source/version/date: http://cppreference.com, 2024.06.10. thatβs the whole page, bestie π«Άπ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms