Minsky
minsky::Optional< T > Struct Template Reference

convenience class to omit writing XML records when data absent or empty More...

#include <optional.h>

Inheritance diagram for minsky::Optional< T >:
Inheritance graph
Collaboration diagram for minsky::Optional< T >:
Collaboration graph

Public Member Functions

 Optional ()
 
 Optional (const T &x)
 
template<class U >
 Optional (const Optional< U > &x)
 
template<class U >
classdesc::enable_if< has_empty< U >, void >::T assign (const U &x, classdesc::dummy< 0 > d=0)
 
template<class U >
classdesc::enable_if< classdesc::Not< has_empty< U > >, void >::T assign (const U &x, classdesc::dummy< 1 > d=0)
 
T & operator* ()
 
const T & operator* () const
 
T * operator-> ()
 
const T * operator-> () const
 
template<class U >
Optionaloperator= (const U &x)
 

Detailed Description

template<class T>
struct minsky::Optional< T >

convenience class to omit writing XML records when data absent or empty

Definition at line 39 of file optional.h.

Constructor & Destructor Documentation

◆ Optional() [1/3]

template<class T>
minsky::Optional< T >::Optional ( )
inline

Definition at line 41 of file optional.h.

41 {}

◆ Optional() [2/3]

template<class T>
minsky::Optional< T >::Optional ( const T &  x)
inline

Definition at line 42 of file optional.h.

42 {assign(x);}
classdesc::enable_if< has_empty< U >, void >::T assign(const U &x, classdesc::dummy< 0 > d=0)
Definition: optional.h:47

◆ Optional() [3/3]

template<class T>
template<class U >
minsky::Optional< T >::Optional ( const Optional< U > &  x)
inline

Definition at line 44 of file optional.h.

44 {if (x) *this=*x;}

Member Function Documentation

◆ assign() [1/2]

template<class T>
template<class U >
classdesc::enable_if<has_empty<U>,void>::T minsky::Optional< T >::assign ( const U &  x,
classdesc::dummy< 0 >  d = 0 
)
inline

Definition at line 47 of file optional.h.

Referenced by minsky::Optional< minsky::ShowSlice >::operator=(), and minsky::Optional< minsky::ShowSlice >::Optional().

47  {
48  if (!x.empty()) this->reset(new T(x));
49  }
reset
Definition: minsky.tcl:1325
Here is the caller graph for this function:

◆ assign() [2/2]

template<class T>
template<class U >
classdesc::enable_if<classdesc::Not<has_empty<U> >,void>::T minsky::Optional< T >::assign ( const U &  x,
classdesc::dummy< 1 >  d = 0 
)
inline

Definition at line 52 of file optional.h.

52 {this->reset(new T(x));}
reset
Definition: minsky.tcl:1325

◆ operator*() [1/2]

template<class T>
T& minsky::Optional< T >::operator* ( )
inline

Definition at line 55 of file optional.h.

55 {if (!this->get()) this->reset(new T); return *this->get();}
reset
Definition: minsky.tcl:1325

◆ operator*() [2/2]

template<class T>
const T& minsky::Optional< T >::operator* ( ) const
inline

Definition at line 56 of file optional.h.

56 {return *this->get();}

◆ operator->() [1/2]

template<class T>
T* minsky::Optional< T >::operator-> ( )
inline

Definition at line 57 of file optional.h.

57 {return &**this;}

◆ operator->() [2/2]

template<class T>
const T* minsky::Optional< T >::operator-> ( ) const
inline

Definition at line 58 of file optional.h.

58 {return &**this;}

◆ operator=()

template<class T>
template<class U >
Optional& minsky::Optional< T >::operator= ( const U &  x)
inline

Definition at line 60 of file optional.h.

60 {assign(x); return *this;}
classdesc::enable_if< has_empty< U >, void >::T assign(const U &x, classdesc::dummy< 0 > d=0)
Definition: optional.h:47

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