|
swift
|
Own implementation of std::optional. More...
Public Member Functions | |
| Optional () noexcept=default | |
| Default constructor. | |
| Optional (T value) noexcept(std::is_nothrow_move_constructible_v< T >) | |
| Construct from a value. | |
| Optional (std::nullptr_t) noexcept | |
| Construct from a nullptr, equivalent to default constructor. | |
| Optional (const Optional &other) noexcept(std::is_nothrow_copy_constructible_v< T >) | |
| Copy constructor. | |
| Optional (Optional &&other) noexcept(std::is_nothrow_move_constructible_v< T >) | |
| Move constructor. | |
| Optional & | operator= (std::nullptr_t) noexcept |
| Assign a nullptr. | |
| Optional & | operator= (const Optional &other) noexcept(std::is_nothrow_copy_constructible_v< T >) |
| Copy assignment. | |
| Optional & | operator= (Optional &&other) noexcept(std::is_nothrow_move_constructible_v< T >) |
| Move assignment. | |
| ~Optional () | |
| Destructor. | |
| operator bool () const noexcept | |
| Explicit cast to bool, true if this Optional contains a value. | |
| void | reset () noexcept |
| If object is valid, destroy to make it invalid. | |
| T & | operator* () |
| Dereference operator, returns reference to contained value, undefined if there is no value contained. | |
| const T & | operator* () const |
| Dereference operator, returns reference to contained value, undefined if there is no value contained. | |
| T * | operator-> () |
| Indirection operator, returns pointer to contained value, undefined if there is no value contained. | |
| const T * | operator-> () const |
| Indirection operator, returns pointer to contained value, undefined if there is no value contained. | |
Own implementation of std::optional.
Needed to work around lack of C++20 copyable lambda functions.
Definition at line 22 of file optional.h.