|
ipaddress 1.2.0
|
A template class to manage an optional contained value. More...
#include <optional.hpp>
Public Types | |
| using | value_type = T |
| The type of the value to manage initialization state for. | |
Public Member Functions | |
| constexpr inline | optional () noexcept(noexcept(T()))=default |
Default constructor that constructs an optional object without a contained value. | |
| constexpr inline | optional (std::nullptr_t) noexcept(noexcept(T())) |
Constructs an optional object that does not contain a value. | |
| constexpr inline | optional (const value_type &val) noexcept(noexcept(T(val))) |
Copy constructor that constructs an optional object with a contained value, initializing it with val. | |
| constexpr inline | optional (value_type &&val) noexcept |
Move constructor that constructs an optional object with a contained value, initializing it with val. | |
| constexpr inline | optional (const optional< T > &opt) noexcept |
Copy constructor that constructs an optional object with a contained value, copying it from opt. | |
| constexpr inline optional & | operator= (std::nullptr_t) noexcept |
Assignment operator that clears the contained value of the optional object. | |
| constexpr inline optional & | operator= (value_type &&val) noexcept |
Move assignment operator that sets the contained value of the optional object to val. | |
| constexpr inline optional & | operator= (const optional< T > &opt) noexcept |
Assigns the value and the state of existence from another optional object. | |
| constexpr inline value_type * | operator-> () noexcept |
| Pointer access to the contained value. | |
| constexpr inline const value_type * | operator-> () const noexcept |
| Constant pointer access to the contained value. | |
| constexpr inline value_type & | operator* () noexcept |
| Reference access to the contained value. | |
| constexpr inline const value_type & | operator* () const noexcept |
| Constant reference access to the contained value. | |
| constexpr inline | operator bool () const noexcept |
| Checks existence of the contained value. | |
| constexpr inline bool | has_value () const noexcept |
| Checks existence of the contained value. | |
| constexpr inline value_type & | value () &noexcept |
| Reference access to the contained value. | |
| constexpr inline const value_type & | value () const &noexcept |
| Constant reference access to the contained value. | |
| constexpr inline value_type && | value () &&noexcept |
| Move access to the contained value. | |
| constexpr inline const value_type && | value () const &&noexcept |
| Constant move access to the contained value. | |
A template class to manage an optional contained value.
The optional class template is often used to represent the outcome of a function that might not succeed. An optional<T> can either hold a value or be empty at any moment. When it does hold a value, that value is stored within the optional object itself, meaning there’s no need for separate dynamic memory allocation. If you check an optional<T> in a boolean context, such as in an if-statement, it will evaluate to true if there’s a value present, and false otherwise.
| T | The type of the value to manage initialization state for. |
|
inlinenoexcept |
Copy constructor that constructs an optional object with a contained value, initializing it with val.
| [in] | val | The value to copy into the optional object. |
|
inlinenoexcept |
Move constructor that constructs an optional object with a contained value, initializing it with val.
| [in,out] | val | The value to move into the optional object. |
Copy constructor that constructs an optional object with a contained value, copying it from opt.
| [in] | opt | The optional object to copy the value from. |
|
inlinenoexcept |
Assignment operator that clears the contained value of the optional object.
optional object.
|
inlinenoexcept |
Move assignment operator that sets the contained value of the optional object to val.
| [in,out] | val | The value to move into the optional object. |
optional object. Assigns the value and the state of existence from another optional object.
| [in] | opt | The optional object to copy from. |
*this.
|
inlinenodiscardnoexcept |
Pointer access to the contained value.
Provides pointer access to the contained value. It is undefined behavior if the optional object does not contain a value.
|
inlinenodiscardnoexcept |
Constant pointer access to the contained value.
Provides constant pointer access to the contained value. It is undefined behavior if the optional object does not contain a value.
|
inlinenodiscardnoexcept |
Reference access to the contained value.
Provides reference access to the contained value. It is undefined behavior if the optional object does not contain a value.
|
inlinenodiscardnoexcept |
Constant reference access to the contained value.
Provides constant reference access to the contained value. It is undefined behavior if the optional object does not contain a value.
|
inlineexplicitnodiscardnoexcept |
Checks existence of the contained value.
Determines whether the optional object contains a value.
true if a value is contained, otherwise false.
|
inlinenodiscardnoexcept |
Checks existence of the contained value.
Determines whether the optional object contains a value.
true if a value is contained, otherwise false.
|
inlinenodiscardnoexcept |
Reference access to the contained value.
Provides reference access to the contained value. It is undefined behavior if the optional object does not contain a value.
|
inlinenodiscardnoexcept |
Constant reference access to the contained value.
Provides constant reference access to the contained value. It is undefined behavior if the optional object does not contain a value.
|
inlinenodiscardnoexcept |
Move access to the contained value.
Moves the contained value. It is undefined behavior if the optional object does not contain a value.
|
inlinenodiscardnoexcept |
Constant move access to the contained value.
Moves the contained value, maintaining constness. It is undefined behavior if the optional object does not contain a value.