mxnet
Public Member Functions | List of all members
dmlc::optional< T > Class Template Reference

c++17 compatible optional class. More...

#include <optional.h>

Collaboration diagram for dmlc::optional< T >:
Collaboration graph

Public Member Functions

 optional ()
 construct an optional object that contains no value More...
 
 optional (const T &value)
 construct an optional object with value More...
 
 optional (const optional< T > &other)
 construct an optional object with another optional object More...
 
 ~optional ()
 deconstructor More...
 
void swap (optional< T > &other)
 swap two optional More...
 
optional< T > & operator= (const T &value)
 set this object to hold value More...
 
optional< T > & operator= (const optional< T > &other)
 set this object to hold the same value with other More...
 
optional< T > & operator= (nullopt_t)
 clear the value this object is holding. optional<T> x = nullopt; More...
 
T & operator* ()
 non-const dereference operator More...
 
const T & operator* () const
 const dereference operator More...
 
bool operator== (const optional< T > &other) const
 equal comparison More...
 
const T & value () const
 return the holded value. throws std::logic_error if holding no value More...
 
 operator bool () const
 whether this object is holding a value More...
 
bool has_value () const
 whether this object is holding a value (alternate form). More...
 

Detailed Description

template<typename T>
class dmlc::optional< T >

c++17 compatible optional class.

At any time an optional<T> instance either hold no value (string representation "None") or hold a value of type T.

Constructor & Destructor Documentation

template<typename T>
dmlc::optional< T >::optional ( )
inline

construct an optional object that contains no value

template<typename T>
dmlc::optional< T >::optional ( const T &  value)
inlineexplicit

construct an optional object with value

template<typename T>
dmlc::optional< T >::optional ( const optional< T > &  other)
inline

construct an optional object with another optional object

template<typename T>
dmlc::optional< T >::~optional ( )
inline

deconstructor

Member Function Documentation

template<typename T>
bool dmlc::optional< T >::has_value ( ) const
inline

whether this object is holding a value (alternate form).

template<typename T>
dmlc::optional< T >::operator bool ( ) const
inlineexplicit

whether this object is holding a value

template<typename T>
T& dmlc::optional< T >::operator* ( )
inline

non-const dereference operator

template<typename T>
const T& dmlc::optional< T >::operator* ( ) const
inline

const dereference operator

template<typename T>
optional<T>& dmlc::optional< T >::operator= ( const T &  value)
inline

set this object to hold value

Parameters
valuethe value to hold
Returns
return self to support chain assignment
template<typename T>
optional<T>& dmlc::optional< T >::operator= ( const optional< T > &  other)
inline

set this object to hold the same value with other

Parameters
otherthe other object
Returns
return self to support chain assignment
template<typename T>
optional<T>& dmlc::optional< T >::operator= ( nullopt_t  )
inline

clear the value this object is holding. optional<T> x = nullopt;

template<typename T>
bool dmlc::optional< T >::operator== ( const optional< T > &  other) const
inline

equal comparison

template<typename T>
void dmlc::optional< T >::swap ( optional< T > &  other)
inline

swap two optional

template<typename T>
const T& dmlc::optional< T >::value ( ) const
inline

return the holded value. throws std::logic_error if holding no value


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