Utilities
Utilities header only library
utils::StrongOptionalType< ValueType, PhantomType > Struct Template Reference

std::optional specialization of the Strong type pattern. More...

Inheritance diagram for utils::StrongOptionalType< ValueType, PhantomType >:
[legend]

Public Types

using OptionalValueType = std::optional< ValueType >
 

Public Member Functions

StrongOptionalType< ValueType, PhantomType > & operator= (const OptionalValueType &value)
 
bool HasValue () const
 Proxy function to access the underlying optional's has_value() function.
 
const ValueType & Value () const
 Proxy function to access the underlying optional's value() function.
 
- Public Member Functions inherited from utils::StrongType< std::optional< ValueType >, PhantomType >
 StrongType (std::optional< ValueType > value)
 
std::enable_if_t< std::is_arithmetic_v< RT >, RT > As () const
 Cast to a specified type. Only work for arithmetic types.
 
bool operator== (const StrongType &other) const
 
bool operator!= (const StrongType &other) const
 
bool operator< (const StrongType &other) const
 
bool operator> (const StrongType &other) const
 
const std::optional< ValueType > & operator* () const
 Get underlying value using the * operator.
 

Additional Inherited Members

- Protected Attributes inherited from utils::StrongType< std::optional< ValueType >, PhantomType >
std::optional< ValueType > value_
 The actual underlying value.
 

Detailed Description

template<typename ValueType, typename PhantomType>
struct utils::StrongOptionalType< ValueType, PhantomType >

std::optional specialization of the Strong type pattern.

Note
Contains value() and has_value() functions to access the underlying optional.