|
SatCat5
|
An optional field that may be filled or empty.
Basic implementation of an std::optional equivalent compatible with C++11. ONLY for use by basic types with trivial default constructors and destructors. https://www.club.cc.cmu.edu/%7Eajo/disseminate/2017-02-15-Optional-From-Scratch.pdf
#include <utils.h>
Public Member Functions | |
| constexpr | optional () |
| Create an empty value. | |
| constexpr | optional (const T &t) |
| Create a filled value. | |
| void | reset () |
| Reset to the empty state. | |
| optional & | operator= (const T &t) |
| Assign a filled value. | |
| T | value () const |
| Fetch the inner value. | |
| T | value_or (const T &t) const |
| Fetch the inner value if present, or the specified default. | |
| bool | has_value () const |
| Is this optional field present? | |
| operator bool () const | |
| Is this optional field present? | |
Private Attributes | |
| T | val_ |
| bool | has_val_ |