#include <Rodin/Utility/OptionalReference.h>
template<typename T>
OptionalReference class
A wrapper providing optional reference semantics.
| 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::
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->() -> T*
- < Inherit constructors
- auto operator*() -> T&
- Dereference operator.
Function documentation
template<typename T>
T* Rodin:: Utility:: OptionalReference<T>:: operator->()
< Inherit constructors
| Returns | Pointer to the referenced object. |
|---|
Pointer access operator.
template<typename T>
T& Rodin:: Utility:: OptionalReference<T>:: operator*()
Dereference operator.
| Returns | Reference to the referenced object. |
|---|