ArmNN
 24.08
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 = OptionalBase
 

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). More...
 
- 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. 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::Optional< T >

Definition at line 270 of file Optional.hpp.

Member Typedef Documentation

◆ BaseSwitch

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

Definition at line 273 of file Optional.hpp.

Constructor & Destructor Documentation

◆ Optional() [1/6]

Optional ( )
inlinenoexcept

Definition at line 275 of file Optional.hpp.

275 : BaseSwitch{} {}

◆ Optional() [2/6]

Optional ( const T &  value)
inline

Definition at line 276 of file Optional.hpp.

276 : BaseSwitch{value} {}

◆ Optional() [3/6]

Optional ( EmptyOptional< T >  empty)
inline

Definition at line 278 of file Optional.hpp.

278 : BaseSwitch{empty} {}

◆ Optional() [4/6]

Optional ( const Optional< T > &  other)
inline

Definition at line 279 of file Optional.hpp.

279 : BaseSwitch{other} {}

◆ Optional() [5/6]

Optional ( const BaseSwitch other)
inline

Definition at line 280 of file Optional.hpp.

280 : BaseSwitch{other} {}

◆ Optional() [6/6]

Optional ( ConstructInPlace  ,
Args &&...  args 
)
inlineexplicit

Definition at line 283 of file Optional.hpp.

283  :
284  BaseSwitch(CONSTRUCT_IN_PLACE, std::forward<Args>(args)...) {}

Member Function Documentation

◆ operator=()

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

◆ operator==()

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  }

The documentation for this class was generated from the following file:
CONSTRUCT_IN_PLACE
#define CONSTRUCT_IN_PLACE
Definition: Optional.hpp:41
armnn::Optional::BaseSwitch
OptionalReferenceSwitch< std::is_reference< T >::value, T > BaseSwitch
Definition: Optional.hpp:273
armnn::OptionalReferenceSwitch< std::is_reference< T >::value, T >::value
const T & value() const
Definition: Optional.hpp:146
armnn::OptionalBase::has_value
bool has_value() const noexcept
Definition: Optional.hpp:53