SatCat5
satcat5::util::optional< T > Struct Template Reference

Detailed Description

template<typename T>
struct satcat5::util::optional< T >

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

Definition at line 53 of file utils.h.

#include <utils.h>

Inheritance diagram for satcat5::util::optional< T >:
[legend]

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.
 
optionaloperator= (const T &t)
 Assign a filled value.
 
value () const
 Fetch the inner value.
 
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

val_
 
bool has_val_
 

The documentation for this struct was generated from the following file: