ForestHub SDK 0.1.0
C++14 LLM SDK for PC and embedded platforms
Loading...
Searching...
No Matches
foresthub::Optional< T > Struct Template Reference

Minimal Optional<T> polyfill for C++14 compatibility. More...

#include <optional.hpp>

Public Member Functions

 Optional ()=default
 Default-construct without a stored value.
 Optional (const T &val)
 Construct with a copy of the given value.
 Optional (T &&val)
 Construct by moving the given value.
bool HasValue () const
 Returns true if a value is stored.
 operator bool () const
 Contextual conversion to bool (true if a value is stored).
const T & operator* () const
 Returns a reference to the stored value (undefined if empty).
T & operator* ()
 Returns a mutable reference to the stored value (undefined if empty).
const T * operator-> () const
 Returns a pointer to the stored value (undefined if empty).
T * operator-> ()
 Returns a mutable pointer to the stored value (undefined if empty).
Optionaloperator= (const T &val)
 Assign a value (sets has_value to true).
Optionaloperator= (T &&val)
 Move-assign a value (sets has_value to true).

Public Attributes

bool has_value = false
 Whether a value is stored.
value {}
 Stored value (default-constructed when empty).

Detailed Description

template<typename T>
struct foresthub::Optional< T >

Minimal Optional<T> polyfill for C++14 compatibility.

Used for non-string optional fields (int, float, structs) where a default/zero value would be ambiguous. String-type optional fields should use plain std::string (empty = not set).


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