ArmNN
 24.02
OptionalReferenceSwitch< IsReference, T > Class Template Reference

The default implementation is the non-reference case. More...

#include <Optional.hpp>

Inheritance diagram for OptionalReferenceSwitch< IsReference, T >:
[legend]
Collaboration diagram for OptionalReferenceSwitch< IsReference, T >:
[legend]

Public Types

using Base = OptionalBase
 

Public Member Functions

 OptionalReferenceSwitch () noexcept
 
 OptionalReferenceSwitch (EmptyOptional) noexcept
 
 OptionalReferenceSwitch (const T &value)
 
template<class... Args>
 OptionalReferenceSwitch (ConstructInPlace, Args &&... args)
 
 OptionalReferenceSwitch (const OptionalReferenceSwitch &other)
 
OptionalReferenceSwitchoperator= (const T &value)
 
OptionalReferenceSwitchoperator= (const OptionalReferenceSwitch &other)
 
OptionalReferenceSwitchoperator= (EmptyOptional)
 
 ~OptionalReferenceSwitch ()
 
void reset ()
 
const T & value () const
 
T & value ()
 
- Public Member Functions inherited from OptionalBase
 OptionalBase () noexcept
 
bool has_value () const noexcept
 
 operator bool () const noexcept
 Conversion to bool, so can be used in if-statements and similar contexts expecting a bool. More...
 

Additional Inherited Members

- Protected Member Functions inherited from OptionalBase
 OptionalBase (bool hasValue) noexcept
 
- Protected Attributes inherited from OptionalBase
bool m_HasValue
 

Detailed Description

template<bool IsReference, typename T>
class armnn::OptionalReferenceSwitch< IsReference, T >

The default implementation is the non-reference case.

This has an unsigned char array for storing the optional value which is in-place constructed there.

Definition at line 81 of file Optional.hpp.

Member Typedef Documentation

◆ Base

using Base = OptionalBase

Definition at line 84 of file Optional.hpp.

Constructor & Destructor Documentation

◆ OptionalReferenceSwitch() [1/5]

OptionalReferenceSwitch ( )
inlinenoexcept

Definition at line 86 of file Optional.hpp.

86 : Base{} {}

◆ OptionalReferenceSwitch() [2/5]

OptionalReferenceSwitch ( EmptyOptional  )
inlinenoexcept

Definition at line 87 of file Optional.hpp.

87 : Base{} {}

◆ OptionalReferenceSwitch() [3/5]

OptionalReferenceSwitch ( const T &  value)
inline

Definition at line 89 of file Optional.hpp.

90  : Base{}
91  {
92  Construct(value);
93  }

◆ OptionalReferenceSwitch() [4/5]

OptionalReferenceSwitch ( ConstructInPlace  ,
Args &&...  args 
)
inline

Definition at line 96 of file Optional.hpp.

97  : Base{}
98  {
99  Construct(CONSTRUCT_IN_PLACE, std::forward<Args>(args)...);
100  }

◆ OptionalReferenceSwitch() [5/5]

OptionalReferenceSwitch ( const OptionalReferenceSwitch< IsReference, T > &  other)
inline

Definition at line 102 of file Optional.hpp.

103  : Base{}
104  {
105  *this = other;
106  }

◆ ~OptionalReferenceSwitch()

Definition at line 132 of file Optional.hpp.

133  {
134  reset();
135  }

Member Function Documentation

◆ operator=() [1/3]

OptionalReferenceSwitch& operator= ( const OptionalReferenceSwitch< IsReference, T > &  other)
inline

Definition at line 115 of file Optional.hpp.

116  {
117  reset();
118  if (other.has_value())
119  {
120  Construct(other.value());
121  }
122 
123  return *this;
124  }

◆ operator=() [2/3]

OptionalReferenceSwitch& operator= ( const T &  value)
inline

Definition at line 108 of file Optional.hpp.

109  {
110  reset();
111  Construct(value);
112  return *this;
113  }

◆ operator=() [3/3]

OptionalReferenceSwitch& operator= ( EmptyOptional  )
inline

Definition at line 126 of file Optional.hpp.

127  {
128  reset();
129  return *this;
130  }

◆ reset()

◆ value() [1/2]

T& value ( )
inline

Definition at line 157 of file Optional.hpp.

158  {
159  if (!Base::has_value())
160  {
161  throw BadOptionalAccessException("Optional has no value");
162  }
163 
164  auto valuePtr = reinterpret_cast<T*>(m_Storage);
165  return *valuePtr;
166  }

◆ value() [2/2]


The documentation for this class was generated from the following file:
CONSTRUCT_IN_PLACE
#define CONSTRUCT_IN_PLACE
Definition: Optional.hpp:41
armnn::OptionalReferenceSwitch::Base
OptionalBase Base
Definition: Optional.hpp:84
armnn::OptionalBase::m_HasValue
bool m_HasValue
Definition: Optional.hpp:72
armnn::OptionalReferenceSwitch::reset
void reset()
Definition: Optional.hpp:137
armnn::OptionalReferenceSwitch::value
const T & value() const
Definition: Optional.hpp:146
armnn::OptionalBase::has_value
bool has_value() const noexcept
Definition: Optional.hpp:53