|
|
| DeferredReference () noexcept=default |
| | Constructs an empty DeferredReference with no bound reference.
|
| |
| | DeferredReference (const T &ref) noexcept |
| | Constructs a non-owning DeferredReference bound to an existing object.
|
| |
| | DeferredReference (const T *ptr) noexcept |
| | Constructs a non-owning DeferredReference bound to a pointer.
|
| |
| const T & | emplace (OwnedT &&value) noexcept(std::is_nothrow_move_constructible_v< OwnedT >) |
| | Moves a value into owned storage and binds to it.
|
| |
|
| operator bool () const noexcept |
| | Checks whether this DeferredReference currently references a valid object.
|
| |
| const T & | get () const noexcept |
| | Gets a const reference to the referenced or owned object.
|
| |
|
const T * | operator-> () const noexcept |
| | Provides pointer-like access to the referenced or owned object.
|
| |
|
const T & | operator* () const noexcept |
| | Dereferences to the referenced or owned object.
|
| |
template<class T>
class musx::dom::DeferredReference< T >
Wraps a reference to an existing object or owns a temporary value if needed.
This utility allows a function parameter to accept either a non-owning reference (bound implicitly from a const T& or const T*) or an owned value created later via emplace(). It avoids copies and enables lazy materialization.
Example usage:
{
if (!foo)
foo.emplace(createFoo());
return foo->bar();
}
Foo f;
func(f);
func();
Wraps a reference to an existing object or owns a temporary value if needed.
Definition MusxInstance.h:179
DeferredReference() noexcept=default
Constructs an empty DeferredReference with no bound reference.
- Template Parameters
-
| T | The public reference type. May be const-qualified (e.g., const Foo). Ownership is always stored as a mutable std::remove_const_t<T> internally. |