cppcore
A small, portable C++ core library
Loading...
Searching...
No Matches
cppcore::TOptional< T > Class Template Reference

This class is used to describe a value which is not valid until it will ge inited. More...

#include <TOptional.h>

Public Member Functions

 TOptional ()=delete
 The default class constructor is deleted.
 TOptional (T defaultValue)
 The class constructor.
 ~TOptional ()=default
 The class destructor.
bool isInited () const
 Will return false, if the value was not set,.
T value ()
 Will return the value or the default value if no init was performed before.
void set (T value)
 Will set the value, the instance will be in init state true afterwards.
T & operator= (const T &value)
 Default operators.
bool operator== (const TOptional< T > &rhs) const
 The copy constructor.

Detailed Description

template<class T>
class cppcore::TOptional< T >

This class is used to describe a value which is not valid until it will ge inited.

Definition at line 36 of file TOptional.h.

Constructor & Destructor Documentation

◆ TOptional() [1/2]

template<class T>
cppcore::TOptional< T >::TOptional ( )
delete

The default class constructor is deleted.

Referenced by operator==(), and ~TOptional().

◆ TOptional() [2/2]

template<class T>
cppcore::TOptional< T >::TOptional ( T defaultValue)
inlineexplicit

The class constructor.

Parameters
[in]defaultValueInit value if no set was performed.

Definition at line 72 of file TOptional.h.

◆ ~TOptional()

template<class T>
cppcore::TOptional< T >::~TOptional ( )
default

The class destructor.

References TOptional(), and value().

Member Function Documentation

◆ isInited()

template<class T>
bool cppcore::TOptional< T >::isInited ( ) const
inline

Will return false, if the value was not set,.

Returns
The init state.

Definition at line 77 of file TOptional.h.

◆ operator=()

template<class T>
T & cppcore::TOptional< T >::operator= ( const T & value)
inline

Default operators.

Definition at line 99 of file TOptional.h.

References value().

◆ operator==()

template<class T>
bool cppcore::TOptional< T >::operator== ( const TOptional< T > & rhs) const
inline

The copy constructor.

Definition at line 109 of file TOptional.h.

References TOptional().

◆ set()

template<class T>
void cppcore::TOptional< T >::set ( T value)
inline

Will set the value, the instance will be in init state true afterwards.

Parameters
[in]valueThe value.

Definition at line 91 of file TOptional.h.

References value().

◆ value()

template<class T>
T cppcore::TOptional< T >::value ( )
inline

Will return the value or the default value if no init was performed before.

Returns
The value or the default value.

Definition at line 82 of file TOptional.h.

Referenced by operator=(), set(), and ~TOptional().


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