|
swift
|
Own implementation of std::optional. More...
#include <optional.h>
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.
|
inlinenoexcept |
Construct from a value.
Definition at line 29 of file optional.h.
|
inlinenoexcept |
Construct from a nullptr, equivalent to default constructor.
Definition at line 36 of file optional.h.
|
inlinenoexcept |
Copy constructor.
Definition at line 39 of file optional.h.
|
inlinenoexcept |
Move constructor.
Definition at line 49 of file optional.h.
|
inline |
Destructor.
Definition at line 90 of file optional.h.
|
inlineexplicitnoexcept |
Explicit cast to bool, true if this Optional contains a value.
Definition at line 99 of file optional.h.
|
inline |
Dereference operator, returns reference to contained value, undefined if there is no value contained.
Definition at line 112 of file optional.h.
|
inline |
Dereference operator, returns reference to contained value, undefined if there is no value contained.
Definition at line 115 of file optional.h.
|
inline |
Indirection operator, returns pointer to contained value, undefined if there is no value contained.
Definition at line 118 of file optional.h.
|
inline |
Indirection operator, returns pointer to contained value, undefined if there is no value contained.
Definition at line 121 of file optional.h.
|
inlinenoexcept |
Copy assignment.
Definition at line 66 of file optional.h.
|
inlinenoexcept |
Move assignment.
Definition at line 78 of file optional.h.
|
inlinenoexcept |
Assign a nullptr.
Definition at line 59 of file optional.h.
|
inlinenoexcept |
If object is valid, destroy to make it invalid.
Definition at line 102 of file optional.h.