forked from TartanLlama/optional
Publish docs
This commit is contained in:
435
docs/index.md
435
docs/index.md
@ -99,16 +99,24 @@ namespace <a href='doc_optional.html#optional.hpp'>tl</a>
|
||||
constexpr bool <a href='doc_optional.html#tl::operator==(constoptional-T-&,constU&)'>operator>=</a>(const U& lhs, const <a href='doc_optional.html#tl::optional-T-'>optional<T></a>& rhs);
|
||||
|
||||
template <class T>
|
||||
void swap(optional<T> &lhs, optional<T>
|
||||
void swap(optional<T> &lhs, optional<T> &rhs);
|
||||
|
||||
template <class T>
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-'>optional<detail::decay_t<T>></a> <a href='doc_optional.html#optional.hpp'>make_optional</a>(T&& v);
|
||||
namespace <a href='doc_optional.html#optional.hpp'>detail</a>
|
||||
{
|
||||
struct <a href='doc_optional.html#optional.hpp'>i_am_secret</a>;
|
||||
}
|
||||
|
||||
template <class T = detail::i_am_secret, class U, class Ret = detail::conditional_t<std::is_same<T, detail::i_am_secret>::value, detail::decay_t<U>, T>>
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-'>optional<Ret></a> <a href='doc_optional.html#optional.hpp'>make_optional</a>(U&& v);
|
||||
|
||||
template <class T, class ... Args>
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-'>optional<T></a> <a href='doc_optional.html#optional.hpp'>make_optional</a>(Args&&... args);
|
||||
|
||||
template <class T, class U, class ... Args>
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-'>optional<T></a> <a href='doc_optional.html#optional.hpp'>make_optional</a>(<a href='http://en.cppreference.com/mwiki/index.php?title=Special%3ASearch&search=std::initializer_list%3cU%3e'>std::initializer_list<U></a> il, Args&&... args);
|
||||
|
||||
template <class T>
|
||||
class <a href='doc_optional.html#tl::optional-T&-'>optional<T&></a>;
|
||||
}
|
||||
|
||||
namespace <a href='doc_optional.html#optional.hpp'>std</a>
|
||||
@ -229,9 +237,9 @@ public:
|
||||
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-::optional(optional-T-&&)'>optional</a>(<a href='doc_optional.html#tl::optional-T-'>optional</a>&& rhs) = default;
|
||||
|
||||
template <class... Args> constexpr explicit
|
||||
template <class... Args> constexpr explicit optional(in_place_t, Args&&... args);
|
||||
template <class U, class... Args>
|
||||
constexpr explicit
|
||||
constexpr explicit optional(in_place_t, std::initializer_list<U>&, Args&&... args);
|
||||
|
||||
template <class U=T> constexpr optional(U &&u);
|
||||
|
||||
@ -255,9 +263,8 @@ public:
|
||||
|
||||
template <class ... Args>
|
||||
T& <a href='doc_optional.html#tl::optional-T-::emplace(Args&&...)'>emplace</a>(Args&&... args);
|
||||
|
||||
template <class U, class... Args>
|
||||
T&
|
||||
T& emplace(std::initializer_list<U> il, Args &&... args);
|
||||
|
||||
void <a href='doc_optional.html#tl::optional-T-::swap(optional-T-&)'>swap</a>(<a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) noexcept(std::is_nothrow_move_constructible<T>::value&&detail::is_nothrow_swappable<T>::value);
|
||||
|
||||
@ -270,7 +277,7 @@ public:
|
||||
constexpr bool <a href='doc_optional.html#tl::optional-T-::has_value()const'>has_value</a>() const noexcept;
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-::has_value()const'>operator bool</a>() const noexcept;
|
||||
|
||||
constexpr T& <a href='doc_optional.html#tl::optional-T-::value()&'>value</a>() &;
|
||||
constexpr T &value();
|
||||
constexpr const T &value() const;
|
||||
|
||||
template <class U>
|
||||
@ -323,7 +330,9 @@ Carries out some operation on the stored object if there is one.
|
||||
|
||||
Calls `f` if the optional is empty
|
||||
|
||||
*Requires*: `std::invoke_result_t<F>` must be void or convertible to `optional<T>`. \\effects If `*this` has a value, returns `*this`. Otherwise, if `f` returns `void`, calls `std::forward<F>(f)` and returns `std::nullopt`. Otherwise, returns `std::forward<F>(f)()`.
|
||||
*Requires*: `std::invoke_result_t<F>` must be void or convertible to `optional<T>`.
|
||||
|
||||
*Effects*: If `*this` has a value, returns `*this`. Otherwise, if `f` returns `void`, calls `std::forward<F>(f)` and returns `std::nullopt`. Otherwise, returns `std::forward<F>(f)()`.
|
||||
|
||||
### Function template `tl::optional::map_or`<a id="tl::optional-T-::map_or(F&&,U&&)&"></a>
|
||||
|
||||
@ -408,7 +417,7 @@ Takes the value out of the optional, leaving it empty
|
||||
|
||||
Constructs an optional that does not contain a value.
|
||||
|
||||
### Constructor `tl::optional::optional`<a id="tl::optional-T-::optional(constoptional-T-&)"></a>
|
||||
### Copy constructor `tl::optional::optional`<a id="tl::optional-T-::optional(constoptional-T-&)"></a>
|
||||
|
||||
<pre><code class="language-cpp">constexpr optional(const <a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) = default;</code></pre>
|
||||
|
||||
@ -416,7 +425,7 @@ Copy constructor
|
||||
|
||||
If `rhs` contains a value, the stored value is direct-initialized with it. Otherwise, the constructed optional is empty.
|
||||
|
||||
### Constructor `tl::optional::optional`<a id="tl::optional-T-::optional(optional-T-&&)"></a>
|
||||
### Move constructor `tl::optional::optional`<a id="tl::optional-T-::optional(optional-T-&&)"></a>
|
||||
|
||||
<pre><code class="language-cpp">constexpr optional(<a href='doc_optional.html#tl::optional-T-'>optional</a>&& rhs) = default;</code></pre>
|
||||
|
||||
@ -426,15 +435,13 @@ If `rhs` contains a value, the stored value is direct-initialized with it. Other
|
||||
|
||||
### Function template `tl::optional::optional`<a id="tl::optional-T-::optional(detail::enable_if_t-std::is_constructible-T,Args...-::value,in_place_t-,Args&&...)"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) template <class... Args> constexpr explicit
|
||||
<pre><code class="language-cpp">(1) template <class... Args> constexpr explicit optional(in_place_t, Args&&... args);
|
||||
|
||||
(2) template <class U, class... Args>
|
||||
constexpr explicit</code></pre>
|
||||
constexpr explicit optional(in_place_t, std::initializer_list<U>&, Args&&... args);</code></pre>
|
||||
|
||||
Constructs the stored value in-place using the given arguments.
|
||||
|
||||
optional(in\_place\_t, Args&&... args);
|
||||
|
||||
### Function template `tl::optional::optional`<a id="tl::optional-T-::optional(U&&)"></a>
|
||||
|
||||
<pre><code class="language-cpp">template <class U=T> constexpr optional(U &&u);</code></pre>
|
||||
@ -507,17 +514,13 @@ Moves the value from `rhs` if there is one. Otherwise resets the stored value in
|
||||
|
||||
### Function template `tl::optional::emplace`<a id="tl::optional-T-::emplace(Args&&...)"></a>
|
||||
|
||||
<pre><code class="language-cpp">template <class ... Args>
|
||||
T& emplace(Args&&... args);</code></pre>
|
||||
<pre><code class="language-cpp">(1) template <class ... Args>
|
||||
T& emplace(Args&&... args);
|
||||
|
||||
Constructs the value in-place, destroying the current one if there is one. \\group emplace
|
||||
(2) template <class U, class... Args>
|
||||
T& emplace(std::initializer_list<U> il, Args &&... args);</code></pre>
|
||||
|
||||
### Function template `tl::optional::emplace`<a id="tl::optional-T-::emplace(std::initializer_list-U-,Args&&...)"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) template <class U, class... Args>
|
||||
T&</code></pre>
|
||||
|
||||
emplace(std::initializer\_list\<U\> il, Args &&... args);
|
||||
Constructs the value in-place, destroying the current one if there is one.
|
||||
|
||||
### Function `tl::optional::swap`<a id="tl::optional-T-::swap(optional-T-&)"></a>
|
||||
|
||||
@ -557,14 +560,12 @@ If neither optionals have a value, nothing happens. If both have a value, the va
|
||||
|
||||
### Function `tl::optional::value`<a id="tl::optional-T-::value()&"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) constexpr T& value() &;
|
||||
<pre><code class="language-cpp">(1) constexpr T &value();
|
||||
|
||||
(2) constexpr const T &value() const;</code></pre>
|
||||
|
||||
*Returns*: the contained value if there is one, otherwise throws \[bad\_optional\_access\]
|
||||
|
||||
synopsis constexpr T \&value();
|
||||
|
||||
### Function template `tl::optional::value_or`<a id="tl::optional-T-::value_or(U&&)const&"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) template <class U>
|
||||
@ -691,11 +692,385 @@ Compares the optional with a value.
|
||||
|
||||
If the optional has a value, it is compared with the other value using `T`s relational operators. Otherwise, the optional is considered less than the value.
|
||||
|
||||
## Function template `tl::swap`<a id="tl::swap(optional-T-&,optional-T-&)"></a>
|
||||
## Class template `tl::optional<T&>`<a id="tl::optional-T&-"></a>
|
||||
|
||||
<pre><code class="language-cpp">template <class T>
|
||||
void swap(optional<T> &lhs, optional<T></code></pre>
|
||||
class optional<T&>
|
||||
{
|
||||
public:
|
||||
template <class F>
|
||||
constexpr auto and_then(F &&f) &;
|
||||
template <class F>
|
||||
constexpr auto and_then(F &&f) &&;
|
||||
template <class F>
|
||||
constexpr auto and_then(F &&f) const &;
|
||||
template <class F>
|
||||
constexpr auto and_then(F &&f) const &&;
|
||||
|
||||
template <class F> constexpr auto map(F &&f) &;
|
||||
template <class F> constexpr auto map(F &&f) &&;
|
||||
template <class F> constexpr auto map(F &&f) const&;
|
||||
template <class F> constexpr auto map(F &&f) const&&;
|
||||
|
||||
template <class F> optional<T> or_else (F &&f) &;
|
||||
template <class F> optional<T> or_else (F &&f) &&;
|
||||
template <class F> optional<T> or_else (F &&f) const &;
|
||||
|
||||
template <class F, class U>
|
||||
U <a href='doc_optional.html#tl::optional-T&-::map_or(F&&,U&&)&'>map_or</a>(F&& f, U&& u) &;
|
||||
template <class F, class U>
|
||||
U <a href='doc_optional.html#tl::optional-T&-::map_or(F&&,U&&)&'>map_or</a>(F&& f, U&& u) &&;
|
||||
template <class F, class U>
|
||||
U <a href='doc_optional.html#tl::optional-T&-::map_or(F&&,U&&)&'>map_or</a>(F&& f, U&& u) const &;
|
||||
template <class F, class U>
|
||||
U <a href='doc_optional.html#tl::optional-T&-::map_or(F&&,U&&)&'>map_or</a>(F&& f, U&& u) const &&;
|
||||
|
||||
template <class F, class U>
|
||||
auto map_or_else(F &&f, U &&u) &;
|
||||
template <class F, class U>
|
||||
auto map_or_else(F &&f, U &&u)
|
||||
template <class F, class U>
|
||||
auto map_or_else(F &&f, U &&u)
|
||||
template <class F, class U>
|
||||
auto map_or_else(F &&f, U &&u)
|
||||
|
||||
template <class U>
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-'>optional<typename std::decay<U>::type></a> <a href='doc_optional.html#tl::optional-T&-::conjunction(U&&)const'>conjunction</a>(U&& u) const;
|
||||
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> <a href='doc_optional.html#tl::optional-T&-::disjunction(constoptional&)&'>disjunction</a>(const <a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) &;
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> <a href='doc_optional.html#tl::optional-T&-::disjunction(constoptional&)&'>disjunction</a>(const <a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) const &;
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> <a href='doc_optional.html#tl::optional-T&-::disjunction(constoptional&)&'>disjunction</a>(const <a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) &&;
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> <a href='doc_optional.html#tl::optional-T&-::disjunction(constoptional&)&'>disjunction</a>(const <a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) const &&;
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> <a href='doc_optional.html#tl::optional-T&-::disjunction(constoptional&)&'>disjunction</a>(<a href='doc_optional.html#tl::optional-T-'>optional</a>&& rhs) &;
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> <a href='doc_optional.html#tl::optional-T&-::disjunction(constoptional&)&'>disjunction</a>(<a href='doc_optional.html#tl::optional-T-'>optional</a>&& rhs) const &;
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> <a href='doc_optional.html#tl::optional-T&-::disjunction(constoptional&)&'>disjunction</a>(<a href='doc_optional.html#tl::optional-T-'>optional</a>&& rhs) &&;
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> <a href='doc_optional.html#tl::optional-T&-::disjunction(constoptional&)&'>disjunction</a>(<a href='doc_optional.html#tl::optional-T-'>optional</a>&& rhs) const &&;
|
||||
|
||||
<a href='doc_optional.html#tl::optional-T-'>optional</a> <a href='doc_optional.html#tl::optional-T&-::take()&'>take</a>() &;
|
||||
<a href='doc_optional.html#tl::optional-T-'>optional</a> <a href='doc_optional.html#tl::optional-T&-::take()&'>take</a>() const &;
|
||||
<a href='doc_optional.html#tl::optional-T-'>optional</a> <a href='doc_optional.html#tl::optional-T&-::take()&'>take</a>() &&;
|
||||
<a href='doc_optional.html#tl::optional-T-'>optional</a> <a href='doc_optional.html#tl::optional-T&-::take()&'>take</a>() const &&;
|
||||
|
||||
using <a href='doc_optional.html#tl::optional-T&-'>value_type</a> = T&;
|
||||
|
||||
constexpr <a href='doc_optional.html#tl::optional-T&-::optional()'>optional</a>() noexcept;
|
||||
constexpr <a href='doc_optional.html#tl::optional-T&-::optional()'>optional</a>(<a href='doc_optional.html#tl::nullopt_t'>nullopt_t</a>) noexcept;
|
||||
|
||||
constexpr <a href='doc_optional.html#tl::optional-T&-::optional(constoptional&)'>optional</a>(const <a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) noexcept = default;
|
||||
|
||||
constexpr <a href='doc_optional.html#tl::optional-T&-::optional(optional&&)'>optional</a>(<a href='doc_optional.html#tl::optional-T-'>optional</a>&& rhs) = default;
|
||||
|
||||
template <class U=T> constexpr optional(U &&u);
|
||||
|
||||
<a href='doc_optional.html#tl::optional-T&-::~optional()'>~optional</a>() = default;
|
||||
|
||||
<a href='doc_optional.html#tl::optional-T-'>optional</a>& <a href='doc_optional.html#tl::optional-T&-::operator=(tl::nullopt_t)'>operator=</a>(<a href='doc_optional.html#tl::nullopt_t'>nullopt_t</a>) noexcept;
|
||||
|
||||
<a href='doc_optional.html#tl::optional-T-'>optional</a>& <a href='doc_optional.html#tl::optional-T&-::operator=(constoptional&)'>operator=</a>(const <a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) = default;
|
||||
|
||||
optional &operator=(U &&u);
|
||||
|
||||
template <class U>
|
||||
<a href='doc_optional.html#tl::optional-T-'>optional</a>& <a href='doc_optional.html#tl::optional-T&-::operator=(constoptional-U-&)'>operator=</a>(const <a href='doc_optional.html#tl::optional-T-'>optional<U></a>& rhs);
|
||||
|
||||
template <class ... Args>
|
||||
T& <a href='doc_optional.html#tl::optional-T&-::emplace(Args&&...)'>emplace</a>(Args&&... args) noexcept;
|
||||
|
||||
void <a href='doc_optional.html#tl::optional-T&-::swap(optional&)'>swap</a>(<a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) noexcept;
|
||||
|
||||
constexpr const T *operator->() const;
|
||||
constexpr T *operator->();
|
||||
|
||||
constexpr T &operator*();
|
||||
constexpr const T &operator*() const;
|
||||
|
||||
constexpr bool <a href='doc_optional.html#tl::optional-T&-::has_value()const'>has_value</a>() const noexcept;
|
||||
constexpr <a href='doc_optional.html#tl::optional-T&-::has_value()const'>operator bool</a>() const noexcept;
|
||||
|
||||
constexpr T& <a href='doc_optional.html#tl::optional-T&-::value()&'>value</a>() &;
|
||||
constexpr const T &value() const;
|
||||
|
||||
template <class U>
|
||||
constexpr T <a href='doc_optional.html#tl::optional-T&-::value_or(U&&)const&'>value_or</a>(U&& u) const &;
|
||||
template <class U>
|
||||
constexpr T <a href='doc_optional.html#tl::optional-T&-::value_or(U&&)const&'>value_or</a>(U&& u) &&;
|
||||
|
||||
void <a href='doc_optional.html#tl::optional-T&-::reset()'>reset</a>() noexcept;
|
||||
};</code></pre>
|
||||
|
||||
\&rhs);
|
||||
Specialization for when `T` is a reference. `optional<T&>` acts similarly to a `T*`, but provides more operations and shows intent more clearly.
|
||||
|
||||
*Examples*:
|
||||
|
||||
int i = 42;
|
||||
tl::optional<int&> o = i;
|
||||
*o == 42; //true
|
||||
i = 12;
|
||||
*o = 12; //true
|
||||
&*o == &i; //true
|
||||
|
||||
Assignment has rebind semantics rather than assign-through semantics:
|
||||
|
||||
int j = 8;
|
||||
o = j;
|
||||
|
||||
&*o == &j; //true
|
||||
|
||||
### Function template `tl::optional<T&>::and_then`<a id="tl::optional-T&-::and_then(F&&)&"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) template <class F>
|
||||
constexpr auto and_then(F &&f) &;
|
||||
|
||||
(2) template <class F>
|
||||
constexpr auto and_then(F &&f) &&;
|
||||
|
||||
(3) template <class F>
|
||||
constexpr auto and_then(F &&f) const &;
|
||||
|
||||
(4) template <class F>
|
||||
constexpr auto and_then(F &&f) const &&;</code></pre>
|
||||
|
||||
Carries out some operation which returns an optional on the stored object if there is one. \\requires `std::invoke(std::forward<F>(f), value())` returns a `std::optional<U>` for some `U`. \\returns Let `U` be the result of `std::invoke(std::forward<F>(f), value())`. Returns a `std::optional<U>`. The return value is empty if `*this` is empty, otherwise the return value of `std::invoke(std::forward<F>(f), value())` is returned.
|
||||
|
||||
### Function template `tl::optional<T&>::map`<a id="tl::optional-T&-::map(F&&)&"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) template <class F> constexpr auto map(F &&f) &;
|
||||
|
||||
(2) template <class F> constexpr auto map(F &&f) &&;
|
||||
|
||||
(3) template <class F> constexpr auto map(F &&f) const&;
|
||||
|
||||
(4) template <class F> constexpr auto map(F &&f) const&&;</code></pre>
|
||||
|
||||
Carries out some operation on the stored object if there is one.
|
||||
|
||||
*Returns*: Let `U` be the result of `std::invoke(std::forward<F>(f), value())`. Returns a `std::optional<U>`. The return value is empty if `*this` is empty, otherwise an `optional<U>` is constructed from the return value of `std::invoke(std::forward<F>(f), value())` and is returned.
|
||||
|
||||
### Function template `tl::optional<T&>::or_else`<a id="tl::optional-T&-::or_else(F&&)&"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) template <class F> optional<T> or_else (F &&f) &;
|
||||
|
||||
(2) template <class F> optional<T> or_else (F &&f) &&;
|
||||
|
||||
(3) template <class F> optional<T> or_else (F &&f) const &;</code></pre>
|
||||
|
||||
Calls `f` if the optional is empty
|
||||
|
||||
*Requires*: `std::invoke_result_t<F>` must be void or convertible to `optional<T>`. \\effects If `*this` has a value, returns `*this`. Otherwise, if `f` returns `void`, calls `std::forward<F>(f)` and returns `std::nullopt`. Otherwise, returns `std::forward<F>(f)()`.
|
||||
|
||||
### Function template `tl::optional<T&>::map_or`<a id="tl::optional-T&-::map_or(F&&,U&&)&"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) template <class F, class U>
|
||||
U map_or(F&& f, U&& u) &;
|
||||
|
||||
(2) template <class F, class U>
|
||||
U map_or(F&& f, U&& u) &&;
|
||||
|
||||
(3) template <class F, class U>
|
||||
U map_or(F&& f, U&& u) const &;
|
||||
|
||||
(4) template <class F, class U>
|
||||
U map_or(F&& f, U&& u) const &&;</code></pre>
|
||||
|
||||
Maps the stored value with `f` if there is one, otherwise returns `u`.
|
||||
|
||||
If there is a value stored, then `f` is called with `**this` and the value is returned. Otherwise `u` is returned.
|
||||
|
||||
### Function template `tl::optional<T&>::map_or_else`<a id="tl::optional-T&-::map_or_else(F&&,U&&)&"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) template <class F, class U>
|
||||
auto map_or_else(F &&f, U &&u) &;
|
||||
|
||||
(2) template <class F, class U>
|
||||
auto map_or_else(F &&f, U &&u)
|
||||
|
||||
(3) template <class F, class U>
|
||||
auto map_or_else(F &&f, U &&u)
|
||||
|
||||
(4) template <class F, class U>
|
||||
auto map_or_else(F &&f, U &&u)</code></pre>
|
||||
|
||||
Maps the stored value with `f` if there is one, otherwise calls `u` and returns the result.
|
||||
|
||||
If there is a value stored, then `f` is called with `**this` and the value is returned. Otherwise `std::forward<U>(u)()` is returned.
|
||||
|
||||
### Function template `tl::optional<T&>::conjunction`<a id="tl::optional-T&-::conjunction(U&&)const"></a>
|
||||
|
||||
<pre><code class="language-cpp">template <class U>
|
||||
constexpr <a href='doc_optional.html#tl::optional-T-'>optional<typename std::decay<U>::type></a> conjunction(U&& u) const;</code></pre>
|
||||
|
||||
*Returns*: `u` if `*this` has a value, otherwise an empty optional.
|
||||
|
||||
### Function `tl::optional<T&>::disjunction`<a id="tl::optional-T&-::disjunction(constoptional&)&"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> disjunction(const <a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) &;
|
||||
|
||||
(2) constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> disjunction(const <a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) const &;
|
||||
|
||||
(3) constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> disjunction(const <a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) &&;
|
||||
|
||||
(4) constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> disjunction(const <a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) const &&;
|
||||
|
||||
(5) constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> disjunction(<a href='doc_optional.html#tl::optional-T-'>optional</a>&& rhs) &;
|
||||
|
||||
(6) constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> disjunction(<a href='doc_optional.html#tl::optional-T-'>optional</a>&& rhs) const &;
|
||||
|
||||
(7) constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> disjunction(<a href='doc_optional.html#tl::optional-T-'>optional</a>&& rhs) &&;
|
||||
|
||||
(8) constexpr <a href='doc_optional.html#tl::optional-T-'>optional</a> disjunction(<a href='doc_optional.html#tl::optional-T-'>optional</a>&& rhs) const &&;</code></pre>
|
||||
|
||||
*Returns*: `rhs` if `*this` is empty, otherwise the current value.
|
||||
|
||||
### Function `tl::optional<T&>::take`<a id="tl::optional-T&-::take()&"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) <a href='doc_optional.html#tl::optional-T-'>optional</a> take() &;
|
||||
|
||||
(2) <a href='doc_optional.html#tl::optional-T-'>optional</a> take() const &;
|
||||
|
||||
(3) <a href='doc_optional.html#tl::optional-T-'>optional</a> take() &&;
|
||||
|
||||
(4) <a href='doc_optional.html#tl::optional-T-'>optional</a> take() const &&;</code></pre>
|
||||
|
||||
Takes the value out of the optional, leaving it empty
|
||||
|
||||
### Default constructor `tl::optional<T&>::optional`<a id="tl::optional-T&-::optional()"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) constexpr optional() noexcept;
|
||||
|
||||
(2) constexpr optional(<a href='doc_optional.html#tl::nullopt_t'>nullopt_t</a>) noexcept;</code></pre>
|
||||
|
||||
Constructs an optional that does not contain a value.
|
||||
|
||||
### Copy constructor `tl::optional<T&>::optional`<a id="tl::optional-T&-::optional(constoptional&)"></a>
|
||||
|
||||
<pre><code class="language-cpp">constexpr optional(const <a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) noexcept = default;</code></pre>
|
||||
|
||||
Copy constructor
|
||||
|
||||
If `rhs` contains a value, the stored value is direct-initialized with it. Otherwise, the constructed optional is empty.
|
||||
|
||||
### Move constructor `tl::optional<T&>::optional`<a id="tl::optional-T&-::optional(optional&&)"></a>
|
||||
|
||||
<pre><code class="language-cpp">constexpr optional(<a href='doc_optional.html#tl::optional-T-'>optional</a>&& rhs) = default;</code></pre>
|
||||
|
||||
Move constructor
|
||||
|
||||
If `rhs` contains a value, the stored value is direct-initialized with it. Otherwise, the constructed optional is empty.
|
||||
|
||||
### Function template `tl::optional<T&>::optional`<a id="tl::optional-T&-::optional(U&&)"></a>
|
||||
|
||||
<pre><code class="language-cpp">template <class U=T> constexpr optional(U &&u);</code></pre>
|
||||
|
||||
Constructs the stored value with `u`.
|
||||
|
||||
### Destructor `tl::optional<T&>::~optional`<a id="tl::optional-T&-::~optional()"></a>
|
||||
|
||||
<pre><code class="language-cpp">~optional() = default;</code></pre>
|
||||
|
||||
No-op
|
||||
|
||||
### Assignment operator `tl::optional<T&>::operator=`<a id="tl::optional-T&-::operator=(tl::nullopt_t)"></a>
|
||||
|
||||
<pre><code class="language-cpp"><a href='doc_optional.html#tl::optional-T-'>optional</a>& operator=(<a href='doc_optional.html#tl::nullopt_t'>nullopt_t</a>) noexcept;</code></pre>
|
||||
|
||||
Assignment to empty.
|
||||
|
||||
Destroys the current value if there is one.
|
||||
|
||||
### Copy assignment operator `tl::optional<T&>::operator=`<a id="tl::optional-T&-::operator=(constoptional&)"></a>
|
||||
|
||||
<pre><code class="language-cpp"><a href='doc_optional.html#tl::optional-T-'>optional</a>& operator=(const <a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) = default;</code></pre>
|
||||
|
||||
Copy assignment.
|
||||
|
||||
Rebinds this optional to the referee of `rhs` if there is one. Otherwise resets the stored value in `*this`.
|
||||
|
||||
### Assignment operator `tl::optional<T&>::operator=`<a id="tl::optional-T&-::operator=(U&&)"></a>
|
||||
|
||||
<pre><code class="language-cpp">optional &operator=(U &&u);</code></pre>
|
||||
|
||||
Rebinds this optional to `u`.
|
||||
|
||||
*Requires*: `U` must be an lvalue reference.
|
||||
|
||||
### Assignment operator `tl::optional<T&>::operator=`<a id="tl::optional-T&-::operator=(constoptional-U-&)"></a>
|
||||
|
||||
<pre><code class="language-cpp">template <class U>
|
||||
<a href='doc_optional.html#tl::optional-T-'>optional</a>& operator=(const <a href='doc_optional.html#tl::optional-T-'>optional<U></a>& rhs);</code></pre>
|
||||
|
||||
Converting copy assignment operator.
|
||||
|
||||
Rebinds this optional to the referee of `rhs` if there is one. Otherwise resets the stored value in `*this`.
|
||||
|
||||
### Function template `tl::optional<T&>::emplace`<a id="tl::optional-T&-::emplace(Args&&...)"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) template <class ... Args>
|
||||
T& emplace(Args&&... args) noexcept;</code></pre>
|
||||
|
||||
Constructs the value in-place, destroying the current one if there is one.
|
||||
|
||||
### Function `tl::optional<T&>::swap`<a id="tl::optional-T&-::swap(optional&)"></a>
|
||||
|
||||
<pre><code class="language-cpp">void swap(<a href='doc_optional.html#tl::optional-T-'>optional</a>& rhs) noexcept;</code></pre>
|
||||
|
||||
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.
|
||||
|
||||
### Operator `tl::optional<T&>::operator->`<a id="tl::optional-T&-::operator--()const"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) constexpr const T *operator->() const;
|
||||
|
||||
(2) constexpr T *operator->();</code></pre>
|
||||
|
||||
*Returns*: a pointer to the stored value
|
||||
|
||||
*Requires*: a value is stored
|
||||
|
||||
### Operator `tl::optional<T&>::operator*`<a id="tl::optional-T&-::operator*()&"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) constexpr T &operator*();
|
||||
|
||||
(2) constexpr const T &operator*() const;</code></pre>
|
||||
|
||||
*Returns*: the stored value
|
||||
|
||||
*Requires*: a value is stored
|
||||
|
||||
### Function `tl::optional<T&>::has_value`<a id="tl::optional-T&-::has_value()const"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) constexpr bool has_value() const noexcept;
|
||||
|
||||
(2) constexpr operator bool() const noexcept;</code></pre>
|
||||
|
||||
*Returns*: whether or not the optional has a value
|
||||
|
||||
### Function `tl::optional<T&>::value`<a id="tl::optional-T&-::value()&"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) constexpr T& value() &;
|
||||
|
||||
(2) constexpr const T &value() const;</code></pre>
|
||||
|
||||
*Returns*: the contained value if there is one, otherwise throws \[bad\_optional\_access\]
|
||||
|
||||
synopsis constexpr T \&value();
|
||||
|
||||
### Function template `tl::optional<T&>::value_or`<a id="tl::optional-T&-::value_or(U&&)const&"></a>
|
||||
|
||||
<pre><code class="language-cpp">(1) template <class U>
|
||||
constexpr T value_or(U&& u) const &;
|
||||
|
||||
(2) template <class U>
|
||||
constexpr T value_or(U&& u) &&;</code></pre>
|
||||
|
||||
*Returns*: the stored value if there is one, otherwise returns `u`
|
||||
|
||||
### Function `tl::optional<T&>::reset`<a id="tl::optional-T&-::reset()"></a>
|
||||
|
||||
<pre><code class="language-cpp">void reset() noexcept;</code></pre>
|
||||
|
||||
Destroys the stored value if one exists, making the optional empty
|
||||
|
||||
-----
|
||||
|
||||
-----
|
||||
|
Reference in New Issue
Block a user