69 lines
2.1 KiB
Markdown
69 lines
2.1 KiB
Markdown
[optional.specalg]
|
||
|
||
# 22 General utilities library [[utilities]](./#utilities)
|
||
|
||
## 22.5 Optional objects [[optional]](optional#specalg)
|
||
|
||
### 22.5.10 Specialized algorithms [optional.specalg]
|
||
|
||
[ð](#lib:swap,optional)
|
||
|
||
`template<class T>
|
||
constexpr void swap(optional<T>& x, optional<T>& y) noexcept(noexcept(x.swap(y)));
|
||
`
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L5456)
|
||
|
||
*Constraints*: is_reference_v<T> || (is_move_constructible_v<T> && is_swappable_v<T>) is true[.](#1.sentence-1)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L5463)
|
||
|
||
*Effects*: Calls x.swap(y)[.](#2.sentence-1)
|
||
|
||
[ð](#lib:make_optional)
|
||
|
||
`template<class T> constexpr optional<decay_t<T>> make_optional(T&& v);
|
||
`
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L5474)
|
||
|
||
*Constraints*: The call to make_optional does not use
|
||
an explicit [*template-argument-list*](temp.names#nt:template-argument-list "13.3 Names of template specializations [temp.names]") that
|
||
begins with a type [*template-argument*](temp.names#nt:template-argument "13.3 Names of template specializations [temp.names]")[.](#3.sentence-1)
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L5480)
|
||
|
||
*Returns*: optional<decay_t<T>>(std::forward<T>(v))[.](#4.sentence-1)
|
||
|
||
[ð](#lib:make_optional_)
|
||
|
||
`template<class T, class...Args>
|
||
constexpr optional<T> make_optional(Args&&... args);
|
||
`
|
||
|
||
[5](#5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L5492)
|
||
|
||
*Effects*: Equivalent to: return optional<T>(in_place, std::forward<Args>(args)...);
|
||
|
||
[ð](#lib:make_optional__)
|
||
|
||
`template<class T, class U, class... Args>
|
||
constexpr optional<T> make_optional(initializer_list<U> il, Args&&... args);
|
||
`
|
||
|
||
[6](#6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L5504)
|
||
|
||
*Effects*: Equivalent to: return optional<T>(in_place, il, std::forward<Args>(args)...);
|