Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
Catch::Option< T > Class Template Reference

#include <catch_option.hpp>

Inheritance diagram for Catch::Option< T >:

Public Member Functions

 Option ()
 
 Option (T const &_value)
 
 Option (Option const &_other)
 
 ~Option ()
 
Optionoperator= (Option const &_other)
 
Optionoperator= (T const &_value)
 
void reset ()
 
Toperator* ()
 
T const & operator* () const
 
Toperator-> ()
 
const Toperator-> () const
 
T valueOr (T const &defaultValue) const
 
bool some () const
 
bool none () const
 
bool operator! () const
 
 operator bool () const
 

Detailed Description

template<typename T>
class Catch::Option< T >

Definition at line 15 of file catch_option.hpp.

Constructor & Destructor Documentation

◆ Option() [1/3]

template<typename T >
Catch::Option< T >::Option ( )
inline

Definition at line 17 of file catch_option.hpp.

17: nullableValue( nullptr ) {}

◆ Option() [2/3]

template<typename T >
Catch::Option< T >::Option ( T const & _value)
inline

Definition at line 18 of file catch_option.hpp.

19 : nullableValue( new( storage ) T( _value ) )
20 {}
#define T(meth, val, expected)

◆ Option() [3/3]

template<typename T >
Catch::Option< T >::Option ( Option< T > const & _other)
inline

Definition at line 21 of file catch_option.hpp.

22 : nullableValue( _other ? new( storage ) T( *_other ) : nullptr )
23 {}

◆ ~Option()

template<typename T >
Catch::Option< T >::~Option ( )
inline

Definition at line 25 of file catch_option.hpp.

25 {
26 reset();
27 }
Here is the call graph for this function:

Member Function Documentation

◆ none()

template<typename T >
bool Catch::Option< T >::none ( ) const
inline

Definition at line 59 of file catch_option.hpp.

59{ return nullableValue == nullptr; }

◆ operator bool()

template<typename T >
Catch::Option< T >::operator bool ( ) const
inlineexplicit

Definition at line 62 of file catch_option.hpp.

62 {
63 return some();
64 }
bool some() const
Here is the call graph for this function:

◆ operator!()

template<typename T >
bool Catch::Option< T >::operator! ( ) const
inline

Definition at line 61 of file catch_option.hpp.

61{ return nullableValue == nullptr; }

◆ operator*() [1/2]

template<typename T >
T & Catch::Option< T >::operator* ( )
inline

Definition at line 49 of file catch_option.hpp.

49{ return *nullableValue; }

◆ operator*() [2/2]

template<typename T >
T const & Catch::Option< T >::operator* ( ) const
inline

Definition at line 50 of file catch_option.hpp.

50{ return *nullableValue; }

◆ operator->() [1/2]

template<typename T >
T * Catch::Option< T >::operator-> ( )
inline

Definition at line 51 of file catch_option.hpp.

51{ return nullableValue; }

◆ operator->() [2/2]

template<typename T >
const T * Catch::Option< T >::operator-> ( ) const
inline

Definition at line 52 of file catch_option.hpp.

52{ return nullableValue; }

◆ operator=() [1/2]

template<typename T >
Option & Catch::Option< T >::operator= ( Option< T > const & _other)
inline

Definition at line 29 of file catch_option.hpp.

29 {
30 if( &_other != this ) {
31 reset();
32 if( _other )
33 nullableValue = new( storage ) T( *_other );
34 }
35 return *this;
36 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [2/2]

template<typename T >
Option & Catch::Option< T >::operator= ( T const & _value)
inline

Definition at line 37 of file catch_option.hpp.

37 {
38 reset();
39 nullableValue = new( storage ) T( _value );
40 return *this;
41 }
Here is the call graph for this function:

◆ reset()

template<typename T >
void Catch::Option< T >::reset ( )
inline

Definition at line 43 of file catch_option.hpp.

43 {
44 if( nullableValue )
45 nullableValue->~T();
46 nullableValue = nullptr;
47 }
Here is the caller graph for this function:

◆ some()

template<typename T >
bool Catch::Option< T >::some ( ) const
inline

Definition at line 58 of file catch_option.hpp.

58{ return nullableValue != nullptr; }
Here is the caller graph for this function:

◆ valueOr()

template<typename T >
T Catch::Option< T >::valueOr ( T const & defaultValue) const
inline

Definition at line 54 of file catch_option.hpp.

54 {
55 return nullableValue ? *nullableValue : defaultValue;
56 }
const GenericPointer< typename T::ValueType > T2 defaultValue
Definition pointer.h:1181
Here is the caller graph for this function:

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