ArmNN
 21.02
OptionalReferenceSwitch< true, T > Class Template Reference

This is the special case for reference types. More...

#include <Optional.hpp>

Inheritance diagram for OptionalReferenceSwitch< true, T >:
OptionalBase

Public Types

using Base = OptionalBase
 
using NonRefT = typename std::remove_reference< T >::type
 

Public Member Functions

 OptionalReferenceSwitch () noexcept
 
 OptionalReferenceSwitch (EmptyOptional) noexcept
 
 OptionalReferenceSwitch (const OptionalReferenceSwitch &other)
 
 OptionalReferenceSwitch (T value)
 
template<class... Args>
 OptionalReferenceSwitch (ConstructInPlace, Args &&... args)=delete
 
OptionalReferenceSwitchoperator= (const T value)
 
OptionalReferenceSwitchoperator= (const OptionalReferenceSwitch &other)
 
OptionalReferenceSwitchoperator= (EmptyOptional)
 
 ~OptionalReferenceSwitch ()
 
void reset ()
 
const T value () const
 
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<typename T>
class armnn::OptionalReferenceSwitch< true, T >

This is the special case for reference types.

This holds a pointer to the referenced type. This doesn't own the referenced memory and it never calls delete on the pointer.

Definition at line 191 of file Optional.hpp.

Member Typedef Documentation

◆ Base

using Base = OptionalBase

Definition at line 194 of file Optional.hpp.

◆ NonRefT

using NonRefT = typename std::remove_reference<T>::type

Definition at line 195 of file Optional.hpp.

Constructor & Destructor Documentation

◆ OptionalReferenceSwitch() [1/5]

OptionalReferenceSwitch ( )
inlinenoexcept

Definition at line 197 of file Optional.hpp.

197 : Base{}, m_Storage{nullptr} {}

◆ OptionalReferenceSwitch() [2/5]

OptionalReferenceSwitch ( EmptyOptional  )
inlinenoexcept

Definition at line 198 of file Optional.hpp.

198 : Base{}, m_Storage{nullptr} {}

◆ OptionalReferenceSwitch() [3/5]

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

Definition at line 200 of file Optional.hpp.

200  : Base{}
201  {
202  *this = other;
203  }

◆ OptionalReferenceSwitch() [4/5]

OptionalReferenceSwitch ( value)
inline

Definition at line 205 of file Optional.hpp.

206  : Base{true}
207  , m_Storage{&value}
208  {
209  }

◆ OptionalReferenceSwitch() [5/5]

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

◆ ~OptionalReferenceSwitch()

Definition at line 234 of file Optional.hpp.

235  {
236  reset();
237  }

Member Function Documentation

◆ operator=() [1/3]

OptionalReferenceSwitch& operator= ( const T  value)
inline

Definition at line 214 of file Optional.hpp.

215  {
216  m_Storage = &value;
217  Base::m_HasValue = true;
218  return *this;
219  }

◆ operator=() [2/3]

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

Definition at line 221 of file Optional.hpp.

References OptionalBase::has_value().

222  {
223  m_Storage = other.m_Storage;
224  Base::m_HasValue = other.has_value();
225  return *this;
226  }

◆ operator=() [3/3]

OptionalReferenceSwitch& operator= ( EmptyOptional  )
inline

Definition at line 228 of file Optional.hpp.

229  {
230  reset();
231  return *this;
232  }

◆ reset()

void reset ( )
inline

Definition at line 239 of file Optional.hpp.

240  {
241  Base::m_HasValue = false;
242  m_Storage = nullptr;
243  }

◆ value() [1/2]

const T value ( ) const
inline

Definition at line 245 of file Optional.hpp.

246  {
247  if (!Base::has_value())
248  {
249  throw BadOptionalAccessException("Optional has no value");
250  }
251 
252  return *m_Storage;
253  }

◆ value() [2/2]

T value ( )
inline

Definition at line 255 of file Optional.hpp.

256  {
257  if (!Base::has_value())
258  {
259  throw BadOptionalAccessException("Optional has no value");
260  }
261 
262  return *m_Storage;
263  }

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