ArmNN
 25.11
Loading...
Searching...
No Matches
Optional< T > Class Template Referencefinal

#include <Optional.hpp>

Inheritance diagram for Optional< T >:
[legend]
Collaboration diagram for Optional< T >:
[legend]

Public Types

using BaseSwitch = OptionalReferenceSwitch<std::is_reference<T>::value, T>
Public Types inherited from OptionalReferenceSwitch< std::is_reference< T >::value, T >
using Base

Public Member Functions

 Optional () noexcept
 Optional (const T &value)
Optionaloperator= (const Optional &other)=default
 Optional (EmptyOptional empty)
 Optional (const Optional &other)
 Optional (const BaseSwitch &other)
template<class... Args>
 Optional (ConstructInPlace, Args &&... args)
bool operator== (const Optional< T > &rhs) const
 Two optionals are considered equal if they are both empty or both contain values which themselves are considered equal (via their own == operator).
Public Member Functions inherited from OptionalReferenceSwitch< std::is_reference< T >::value, T >
 OptionalReferenceSwitch () noexcept
 OptionalReferenceSwitch (EmptyOptional) noexcept
 OptionalReferenceSwitch (const T &value)
 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.

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::Optional< T >

Definition at line 270 of file Optional.hpp.

Member Typedef Documentation

◆ BaseSwitch

template<typename T>
using BaseSwitch = OptionalReferenceSwitch<std::is_reference<T>::value, T>

Definition at line 273 of file Optional.hpp.

Constructor & Destructor Documentation

◆ Optional() [1/6]

template<typename T>
Optional ( )
inlinenoexcept

Definition at line 275 of file Optional.hpp.

275: BaseSwitch{} {}

Referenced by operator=(), operator==(), and Optional().

◆ Optional() [2/6]

template<typename T>
Optional ( const T & value)
inline

Definition at line 276 of file Optional.hpp.

276: BaseSwitch{value} {}

References OptionalReferenceSwitch< std::is_reference< T >::value, T >::value().

◆ Optional() [3/6]

template<typename T>
Optional ( EmptyOptional< T > empty)
inline

Definition at line 278 of file Optional.hpp.

278: BaseSwitch{empty} {}

◆ Optional() [4/6]

template<typename T>
Optional ( const Optional< T > & other)
inline

Definition at line 279 of file Optional.hpp.

279: BaseSwitch{other} {}

References Optional().

◆ Optional() [5/6]

template<typename T>
Optional ( const BaseSwitch & other)
inline

Definition at line 280 of file Optional.hpp.

280: BaseSwitch{other} {}

◆ Optional() [6/6]

template<typename T>
template<class... Args>
Optional ( ConstructInPlace ,
Args &&... args )
inlineexplicit

Definition at line 283 of file Optional.hpp.

283 :
284 BaseSwitch(CONSTRUCT_IN_PLACE, std::forward<Args>(args)...) {}
#define CONSTRUCT_IN_PLACE
Definition Optional.hpp:41

References CONSTRUCT_IN_PLACE.

Member Function Documentation

◆ operator=()

template<typename T>
Optional & operator= ( const Optional< T > & other)
default

References Optional().

◆ operator==()

template<typename T>
bool operator== ( const Optional< T > & rhs) const
inline

Two optionals are considered equal if they are both empty or both contain values which themselves are considered equal (via their own == operator).

Definition at line 288 of file Optional.hpp.

289 {
290 if (!this->has_value() && !rhs.has_value())
291 {
292 return true;
293 }
294 if (this->has_value() && rhs.has_value() && this->value() == rhs.value())
295 {
296 return true;
297 }
298 return false;
299 }

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


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