Lumiera  0.pre.03
»edit your freedom«
OptionalRef< T > Class Template Reference

#include "lib/optional-ref.hpp"

Description

template<typename T>
class lib::OptionalRef< T >

Optional or switchable link to an existing object.

This reference wrapper is accessed like a functor, but has the ability to be disabled. This disabled state is managed automatically by ctor and dtor, can be detected through bool check and – contrary to a NULL pointer – produces a real exception instead of crashing.

Note
not taking ownership of the pointee
See also
OptionalRef_test
lib::AutoRegistered usage example
SessionInterfaceModules::~SessionInterfaceModules()

Definition at line 61 of file optional-ref.hpp.

Public Member Functions

 OptionalRef (T &target)
 
void clear ()
 
bool isValid () const
 
void link_to (T &target)
 
 operator bool () const
 
T & operator() () const
 
bool points_to (T const &target) const
 

Friends

bool operator!= (OptionalRef const &r1, OptionalRef const &r2)
 
bool operator!= (T const &otherTarget, OptionalRef const &ref)
 
bool operator!= (OptionalRef const &ref, T const &otherTarget)
 
bool operator== (OptionalRef const &r1, OptionalRef const &r2)
 
bool operator== (OptionalRef const &ref, T const &otherTarget)
 
bool operator== (T const &otherTarget, OptionalRef const &ref)
 

Private Attributes

T * ref_
 

Constructor & Destructor Documentation

◆ OptionalRef()

OptionalRef ( T &  target)
inlineexplicit
Parameters
target...not allowing implicit conversion from T&

Definition at line 79 of file optional-ref.hpp.

Friends And Related Function Documentation

◆ operator==

bool operator== ( OptionalRef< T > const &  ref,
T const &  otherTarget 
)
friend
Parameters
otherTarget
Note
might throw

Definition at line 139 of file optional-ref.hpp.

+ Inheritance diagram for OptionalRef< T >:
+ Collaboration diagram for OptionalRef< T >:

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