fennec
Loading...
Searching...
No Matches
fennec::optional< T >

Structure to hold an optional value. More...

#include <optional.h>

Detailed Description

template<typename T>
struct fennec::optional< T >
Template Parameters
T

Public Member Functions

Constructors & Destructor
constexpr optional ()
 Default Constructor.
 
constexpr optional (nullopt_t)
 Default Constructor.
 
constexpr optional (const T &val)
 Type Copy Constructor.
 
constexpr optional (T &&val)
 Type Move Constructor.
 
constexpr optional (const optional &opt)
 Copy Constructor.
 
constexpr optional (optional &&opt) noexcept
 Move Constructor.
 
Properties
constexpr operator bool () const
 Implicit Boolean Check, returns true when there is a value contained.
 
constexpr bool empty () const
 
Assignment
constexpr optionaloperator= (nullopt_t)
 Fundamental Type Assignment.
 
constexpr optionaloperator= (const T &val) and is_copy_assignable_v< T >
 Type Copy Assignment.
 
constexpr optionaloperator= (T &&val) and is_move_assignable_v< T >
 Type Move Assignment.
 
constexpr optionaloperator= (const optional &opt) and is_copy_assignable_v< T >
 Copy Assignment.
 
constexpr optionaloperator= (optional &&opt) noexcept and is_move_assignable_v< T >
 Move Assignment.
 
Access
constexpr pointer_t operator-> () noexcept
 
constexpr const_pointer_t operator-> () const noexcept
 
constexpr T & operator* () &noexcept
 Dereference Operator.
 
constexpr const T & operator* () const &noexcept
 Const Dereference Operator.
 
constexpr T && operator* () &&noexcept
 Dereference Operator.
 
constexpr const T && operator* () const &&noexcept
 Const Dereference Operator.
 
Modifiers
constexpr T & emplace (T &&val)
 Emplace Assignment, Move overload.
 
constexpr T & emplace (const T &val)
 Emplace Assignment, Copy overload.
 
template<typename... ArgsT>
constexpr T & emplace (ArgsT &&...args)
 Emplace Assignment.
 
void reset ()
 Reset the Optional.
 

Constructor & Destructor Documentation

◆ optional() [1/4]

template<typename T >
constexpr fennec::optional< T >::optional ( const T &  val)
inlineconstexpr
Parameters
valthe value to initialize the underlying object with

◆ optional() [2/4]

template<typename T >
constexpr fennec::optional< T >::optional ( T &&  val)
inlineconstexpr
Parameters
valthe value to initialize the underlying object with

◆ optional() [3/4]

template<typename T >
constexpr fennec::optional< T >::optional ( const optional< T > &  opt)
inlineconstexpr
Parameters
optthe optional to copy

◆ optional() [4/4]

template<typename T >
constexpr fennec::optional< T >::optional ( optional< T > &&  opt)
inlineconstexprnoexcept
Parameters
optthe optional to move

Member Function Documentation

◆ empty()

template<typename T >
constexpr bool fennec::optional< T >::empty ( ) const
inlineconstexpr
Returns
true when there is no held value, false otherwise.

◆ operator=() [1/5]

template<typename T >
constexpr optional & fennec::optional< T >::operator= ( nullopt_t  )
inlineconstexpr
Parameters
valThe value to set with

◆ operator=() [2/5]

template<typename T >
constexpr optional & fennec::optional< T >::operator= ( const T &  val)
inlineconstexpr
Parameters
valThe value to set with

◆ operator=() [3/5]

template<typename T >
constexpr optional & fennec::optional< T >::operator= ( T &&  val)
inlineconstexpr
Parameters
valThe value to set with

◆ operator=() [4/5]

template<typename T >
constexpr optional & fennec::optional< T >::operator= ( const optional< T > &  opt)
inlineconstexpr
Parameters
optThe optional to copy

◆ operator=() [5/5]

template<typename T >
constexpr optional & fennec::optional< T >::operator= ( optional< T > &&  opt)
inlineconstexprnoexcept
Parameters
optThe optional to move

◆ operator->() [1/2]

template<typename T >
constexpr pointer_t fennec::optional< T >::operator-> ( )
inlineconstexprnoexcept
Returns
A pointer to the value, nullptr if there is no value

◆ operator->() [2/2]

template<typename T >
constexpr const_pointer_t fennec::optional< T >::operator-> ( ) const
inlineconstexprnoexcept
Returns
A const-qualified pointer to the value, nullptr if there is no value

◆ operator*() [1/4]

template<typename T >
constexpr T & fennec::optional< T >::operator* ( ) &
inlineconstexprnoexcept
Returns
A reference to the value

◆ operator*() [2/4]

template<typename T >
constexpr const T & fennec::optional< T >::operator* ( ) const &
inlineconstexprnoexcept
Returns
A const-qualified reference to the value

◆ operator*() [3/4]

template<typename T >
constexpr T && fennec::optional< T >::operator* ( ) &&
inlineconstexprnoexcept
Returns
A reference to the value

◆ operator*() [4/4]

template<typename T >
constexpr const T && fennec::optional< T >::operator* ( ) const &&
inlineconstexprnoexcept
Returns
A const-qualified reference to the value

◆ emplace() [1/3]

template<typename T >
constexpr T & fennec::optional< T >::emplace ( T &&  val)
inlineconstexpr
Parameters
valThe object to take ownership of

◆ emplace() [2/3]

template<typename T >
constexpr T & fennec::optional< T >::emplace ( const T &  val)
inlineconstexpr
Parameters
valThe object to copy

◆ emplace() [3/3]

template<typename T >
template<typename... ArgsT>
constexpr T & fennec::optional< T >::emplace ( ArgsT &&...  args)
inlineconstexpr
Parameters
argsThe arguments to construct with

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