opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
osc::ValueOrSentinel< T, Sentinel > Class Template Referencefinal

#include <value_or_sentinel.h>

Public Types

using value_type = T
 

Public Member Functions

constexpr ValueOrSentinel ()=default
 
template<class U = std::remove_cv_t<T>>
requires std::constructible_from<T, U&&>
constexpr ValueOrSentinel (U &&value)
 
constexpr operator bool () const
 
constexpr const T & operator* () const &noexcept
 
constexpr T & operator* () &noexcept
 
constexpr const T && operator* () const &&noexcept
 
constexpr T && operator* () &&noexcept
 
constexpr const T & value () const &
 
constexpr T & value () &
 
constexpr const T && value () const &&
 
constexpr T && value () &&
 

Static Public Member Functions

static constexpr T sentinel ()
 

Friends

constexpr bool operator== (ValueOrSentinel, ValueOrSentinel)=default
 
template<typename U >
constexpr bool operator== (const ValueOrSentinel &lhs, const U &rhs)
 
template<typename U >
constexpr bool operator== (const U &lhs, const ValueOrSentinel &rhs)
 

Detailed Description

template<typename T, T Sentinel>
class osc::ValueOrSentinel< T, Sentinel >

Manages a value, or a sentinel value, which usually means "no value". Useful as an alternative to std::optional<T> when trying to save memory - and when there is an obvious sentinel value.

Member Typedef Documentation

◆ value_type

template<typename T , T Sentinel>
using osc::ValueOrSentinel< T, Sentinel >::value_type = T

Constructor & Destructor Documentation

◆ ValueOrSentinel() [1/2]

template<typename T , T Sentinel>
constexpr osc::ValueOrSentinel< T, Sentinel >::ValueOrSentinel ( )
constexprdefault

◆ ValueOrSentinel() [2/2]

template<typename T , T Sentinel>
template<class U = std::remove_cv_t<T>>
requires std::constructible_from<T, U&&>
constexpr osc::ValueOrSentinel< T, Sentinel >::ValueOrSentinel ( U &&  value)
inlineconstexpr

Member Function Documentation

◆ operator bool()

template<typename T , T Sentinel>
constexpr osc::ValueOrSentinel< T, Sentinel >::operator bool ( ) const
inlineexplicitconstexpr

◆ operator*() [1/4]

template<typename T , T Sentinel>
constexpr T && osc::ValueOrSentinel< T, Sentinel >::operator* ( ) &&
inlineconstexprnoexcept

◆ operator*() [2/4]

template<typename T , T Sentinel>
constexpr T & osc::ValueOrSentinel< T, Sentinel >::operator* ( ) &
inlineconstexprnoexcept

◆ operator*() [3/4]

template<typename T , T Sentinel>
constexpr const T && osc::ValueOrSentinel< T, Sentinel >::operator* ( ) const &&
inlineconstexprnoexcept

◆ operator*() [4/4]

template<typename T , T Sentinel>
constexpr const T & osc::ValueOrSentinel< T, Sentinel >::operator* ( ) const &
inlineconstexprnoexcept

◆ sentinel()

template<typename T , T Sentinel>
static constexpr T osc::ValueOrSentinel< T, Sentinel >::sentinel ( )
inlinestaticconstexpr

◆ value() [1/4]

template<typename T , T Sentinel>
constexpr T & osc::ValueOrSentinel< T, Sentinel >::value ( ) &
inlineconstexpr

◆ value() [2/4]

template<typename T , T Sentinel>
constexpr T && osc::ValueOrSentinel< T, Sentinel >::value ( ) &&
inlineconstexpr

◆ value() [3/4]

template<typename T , T Sentinel>
constexpr const T & osc::ValueOrSentinel< T, Sentinel >::value ( ) const &
inlineconstexpr

◆ value() [4/4]

template<typename T , T Sentinel>
constexpr const T && osc::ValueOrSentinel< T, Sentinel >::value ( ) const &&
inlineconstexpr

Friends And Related Symbol Documentation

◆ operator== [1/3]

template<typename T , T Sentinel>
template<typename U >
constexpr bool operator== ( const U &  lhs,
const ValueOrSentinel< T, Sentinel > &  rhs 
)
friend

◆ operator== [2/3]

template<typename T , T Sentinel>
template<typename U >
constexpr bool operator== ( const ValueOrSentinel< T, Sentinel > &  lhs,
const U &  rhs 
)
friend

◆ operator== [3/3]

template<typename T , T Sentinel>
constexpr bool operator== ( ValueOrSentinel< T, Sentinel >  ,
ValueOrSentinel< T, Sentinel >   
)
friend

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