Opt< T && > Class Template Reference

#include <optional.h>

Detailed Description

template<typename T>
class maxon::Opt< T && >

Specialization to store rvalue references, which only uses a single pointer internally. This can be used to treat pointers that may be null as optional references for more descriptive interfaces.

Public Types

using ValueType = T &&
 
template<typename SUPER >
using ResultFunctions = maxon::details::ResultOptFunctions< SUPER >
 

Public Member Functions

 Opt ()
 
MAXON_IMPLICIT Opt (NO_VALUE_TYPE)
 
 Opt (const Opt &src)=delete
 
Optoperator= (const Opt &)=delete
 
 Opt (Opt &&src)
 
Optoperator= (Opt &&src)
 
MAXON_IMPLICIT Opt (typename std::remove_reference< T >::type &&value)
 
Bool HasValue () const
 
 operator Bool ()
 
 operator Bool () const
 
Result< T > MoveValue ()
 
Result< T && > GetValue () const
 
T && GetValueOr (T &&defaultValue) const
 
T && operator* ()
 
 operator T* ()
 
 operator const T * ()
 

Private Member Functions

MAXON_ATTRIBUTE_FORCE_INLINE void CheckValue () const
 

Private Attributes

T * _dataPtr
 

Member Typedef Documentation

◆ ValueType

using ValueType = T&&

◆ ResultFunctions

Constructor & Destructor Documentation

◆ Opt() [1/5]

Opt ( )

Default constructor. Creates an Opt with no value.

◆ Opt() [2/5]

Explicit construction with NO_VALUE. Has the same effect as the default constructor.

◆ Opt() [3/5]

Opt ( const Opt< T && > &  src)
delete

Deleted copy constructor.

◆ Opt() [4/5]

Opt ( Opt< T && > &&  src)

Move constructor.

◆ Opt() [5/5]

MAXON_IMPLICIT Opt ( typename std::remove_reference< T >::type &&  value)

Constructs from rvalue reference.

Member Function Documentation

◆ operator=() [1/2]

Opt& operator= ( const Opt< T && > &  )
delete

Deleted copy assignment.

◆ operator=() [2/2]

Opt& operator= ( Opt< T && > &&  src)

Move assignment.

◆ HasValue()

Bool HasValue ( ) const

Returns true if this object contains a value.

◆ operator Bool() [1/2]

operator Bool ( )
explicit

◆ operator Bool() [2/2]

operator Bool ( ) const
explicit

◆ MoveValue()

Result<T> MoveValue ( )

Returns the moved out contained value, or IllegalState error if Opt contained no value.

◆ GetValue()

Result<T&&> GetValue ( void  ) const

Returns the contained value, or IllegalState error if object contained no value.

◆ GetValueOr()

T&& GetValueOr ( T &&  defaultValue) const

Returns the contained value, or a default value if object contained no value.

◆ operator*()

T&& operator* ( )

Returns a rvalue reference to the contained value. Results in undefined behavior if object contained no value.

◆ operator T*()

operator T* ( )

Converts the optional reference to a raw pointer. This is supported for interoperability with legacy code.

◆ operator const T *()

operator const T * ( )

◆ CheckValue()

MAXON_ATTRIBUTE_FORCE_INLINE void CheckValue ( ) const
private

Member Data Documentation

◆ _dataPtr

T* _dataPtr
private