ORIGINAL
|
A type-safe container that may or may not contain a value. More...
#include <optional.h>
Public Member Functions | |
alternative () | |
Constructs an empty alternative. | |
template<typename... Args> | |
alternative (Args &&... args) | |
Constructs an alternative containing a value. | |
alternative (const alternative &other) | |
Copy constructor. | |
alternative & | operator= (const alternative &other) |
Copy assignment. | |
alternative (alternative &&other) noexcept | |
Move constructor. | |
alternative & | operator= (alternative &&other) noexcept |
Move assignment. | |
const TYPE & | operator* () const |
Const value access. | |
TYPE & | operator* () |
Mutable value access. | |
const TYPE * | operator-> () const |
Const member access. | |
TYPE * | operator-> () |
Mutable member access. | |
const TYPE * | get () const |
Gets const pointer to value. | |
TYPE * | get () |
Gets mutable pointer to value. | |
void | reset () noexcept |
Resets to empty state. | |
template<typename... Args> | |
void | emplace (Args &&... args) |
Constructs value in-place. | |
void | set (const TYPE &t) |
Sets value by copy. | |
operator bool () const | |
Checks if contains a value. | |
bool | hasValue () const |
Checks if contains a value. | |
~alternative () | |
Destructor. | |
A type-safe container that may or may not contain a value.
Specialization for void type alternative.
TYPE | The type of value to store |
This class provides a way to represent optional values without using pointers. It can either contain a value of type TYPE or be empty. The empty state is represented using original::none from types.h.
Example usage:
Represents a simple boolean flag indicating presence or absence of a value without storing actual data. Useful for signaling states without associated data.
|
explicit |
Constructs an empty alternative.
|
explicit |
Constructs an alternative containing a value.
Args | Argument types for TYPE construction |
args | Arguments to forward to TYPE constructor |
original::alternative< TYPE >::alternative | ( | const alternative< TYPE > & | other | ) |
Copy constructor.
other | Alternative to copy from |
|
noexcept |
Move constructor.
other | Alternative to move from |
original::alternative< TYPE >::~alternative | ( | ) |
Destructor.
void original::alternative< TYPE >::emplace | ( | Args &&... | args | ) |
Constructs value in-place.
Args | Argument types for TYPE construction |
args | Arguments to forward to TYPE constructor |
TYPE * original::alternative< TYPE >::get | ( | ) |
Gets mutable pointer to value.
const TYPE * original::alternative< TYPE >::get | ( | ) | const |
Gets const pointer to value.
|
nodiscard |
Checks if contains a value.
|
explicit |
Checks if contains a value.
TYPE & original::alternative< TYPE >::operator* | ( | ) |
const TYPE & original::alternative< TYPE >::operator* | ( | ) | const |
TYPE * original::alternative< TYPE >::operator-> | ( | ) |
const TYPE * original::alternative< TYPE >::operator-> | ( | ) | const |
|
noexcept |
Move assignment.
other | Alternative to move from |
original::alternative< TYPE > & original::alternative< TYPE >::operator= | ( | const alternative< TYPE > & | other | ) |
Copy assignment.
other | Alternative to copy from |
|
noexcept |
Resets to empty state.
void original::alternative< TYPE >::set | ( | const TYPE & | t | ) |