ArmNN
 26.01
Loading...
Searching...
No Matches
OptionalReferenceSwitch< true, T > Class Template Reference

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

#include <Optional.hpp>

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

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.
 

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

template<typename T >
using Base = OptionalBase

Definition at line 194 of file Optional.hpp.

◆ NonRefT

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

Definition at line 195 of file Optional.hpp.

Constructor & Destructor Documentation

◆ OptionalReferenceSwitch() [1/5]

template<typename T >
OptionalReferenceSwitch ( )
inlinenoexcept

Definition at line 197 of file Optional.hpp.

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

◆ OptionalReferenceSwitch() [2/5]

template<typename T >
OptionalReferenceSwitch ( EmptyOptional )
inlinenoexcept

Definition at line 198 of file Optional.hpp.

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

◆ OptionalReferenceSwitch() [3/5]

template<typename T >
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]

template<typename T >
OptionalReferenceSwitch ( T value)
inline

Definition at line 205 of file Optional.hpp.

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

◆ OptionalReferenceSwitch() [5/5]

template<typename T >
template<class... Args>
OptionalReferenceSwitch ( ConstructInPlace ,
Args &&... args )
delete

◆ ~OptionalReferenceSwitch()

template<typename T >
~OptionalReferenceSwitch ( )
inline

Member Function Documentation

◆ operator=() [1/3]

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

Definition at line 221 of file Optional.hpp.

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

References OptionalBase::has_value(), and OptionalBase::m_HasValue.

◆ operator=() [2/3]

template<typename T >
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 }

References OptionalBase::m_HasValue, and OptionalReferenceSwitch< IsReference, T >::value().

◆ operator=() [3/3]

template<typename T >
OptionalReferenceSwitch & operator= ( EmptyOptional )
inline

Definition at line 228 of file Optional.hpp.

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

References OptionalReferenceSwitch< IsReference, T >::reset().

◆ reset()

template<typename T >
void reset ( )
inline

Definition at line 239 of file Optional.hpp.

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

References OptionalBase::m_HasValue.

◆ value() [1/2]

template<typename T >
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 }
bool has_value() const noexcept
Definition Optional.hpp:53

References OptionalBase::has_value().

◆ value() [2/2]

template<typename T >
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 }

References OptionalBase::has_value().


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