OptionalReference
A wrapper providing optional reference semantics.
Defined in Rodin/Utility/OptionalReference.h
template < typename T> class OptionalReference;
| Template parameters | |
|---|---|
| T | The referenced type. |
OptionalReference provides a way to have an optional reference, combining the functionality of std::optional with reference semantics. This is useful when a function may or may not return a reference to an object.
The class inherits from Optional<std::reference_wrapper<T>> and provides convenient pointer-like and reference access operators.
Example usage:
int value = 42; OptionalReference<int> optRef; // Empty optional reference optRef = value; // Now refers to value if (optRef) { *optRef = 100; // Modifies value through the reference }
Public types
Public functions
- auto operator->() const -> T*
- < Inherit constructors
- auto operator*() const -> T&
- Dereference operator.
Typedef documentation
Function documentation
T* operator->() const
< Inherit constructors
| Returns | Pointer to the referenced object. |
|---|
Pointer access operator.