5#ifndef FORESTHUB_UTIL_OPTIONAL_HPP
6#define FORESTHUB_UTIL_OPTIONAL_HPP
38 explicit operator bool()
const {
return has_value; }
59 value = std::move(val);
Top-level namespace for the ForestHub SDK.
Optional & operator=(T &&val)
Move-assign a value (sets has_value to true).
Definition optional.hpp:57
const T & operator*() const
Returns a reference to the stored value (undefined if empty).
Definition optional.hpp:41
Optional(const T &val)
Construct with a copy of the given value.
Definition optional.hpp:29
T * operator->()
Returns a mutable pointer to the stored value (undefined if empty).
Definition optional.hpp:47
T value
Stored value (default-constructed when empty).
Definition optional.hpp:23
Optional()=default
Default-construct without a stored value.
T & operator*()
Returns a mutable reference to the stored value (undefined if empty).
Definition optional.hpp:43
bool has_value
Whether a value is stored.
Definition optional.hpp:22
const T * operator->() const
Returns a pointer to the stored value (undefined if empty).
Definition optional.hpp:45
Optional & operator=(const T &val)
Assign a value (sets has_value to true).
Definition optional.hpp:50
Optional(T &&val)
Construct by moving the given value.
Definition optional.hpp:32
bool HasValue() const
Returns true if a value is stored.
Definition optional.hpp:35