ErasedUnique Struct
Type-erased unique ownership wrapper. More...
Declaration
Public Constructors Index
| ErasedUnique ()=default | |
|
Default constructor. Creates an empty (non-owning) instance. More... | |
template <class T> | |
| ErasedUnique (std::unique_ptr< T > p) noexcept | |
|
Constructs from a unique_ptr, taking ownership. More... | |
| ErasedUnique (ErasedUnique &&obj) noexcept | |
|
Move constructor. Transfers ownership. More... | |
Public Destructor Index
| ~ErasedUnique () | |
|
Destructor. Destroys the owned object if present. More... | |
Public Operators Index
| ErasedUnique & | operator= (ErasedUnique &&obj) noexcept |
|
Move assignment. Transfers ownership after releasing current. More... | |
Public Member Functions Index
| void | reset () noexcept |
|
Destroys the owned object and resets to empty. More... | |
Public Member Attributes Index
| void * | ptr = nullptr |
|
Raw pointer to the owned object. More... | |
| void(* | destroy)(void *) noexcept = nullptr |
|
Stateless deleter that knows the concrete type. More... | |
Description
Type-erased unique ownership wrapper.
ErasedUnique provides `unique_ptr`-like ownership semantics without requiring a common base class or virtual destructor. It stores a `void*` and a stateless deleter function pointer, totaling 16 bytes.
Used by ResourceRegistry to store heterogeneous resource types (Managers, CommandBuffers) in a single owning collection without vtable overhead for destruction.
## Move-Only Semantics
ErasedUnique is move-only. Moving transfers ownership and nulls the source. Copy construction and assignment are implicitly deleted.
- See Also
ResourceRegistry
Definition at line 31 of file ErasedUnique.ixx.
Public Constructors
ErasedUnique()
| default |
Default constructor. Creates an empty (non-owning) instance.
Definition at line 46 of file ErasedUnique.ixx.
Referenced by ErasedUnique and operator=.
ErasedUnique()
| inline explicit noexcept |
Constructs from a unique_ptr, taking ownership.
Releases the unique_ptr and captures a typed deleter.
- Template Parameters
-
T The owned type.
- Parameters
-
p The unique_ptr to take ownership from.
Definition at line 58 of file ErasedUnique.ixx.
ErasedUnique()
| inline noexcept |
Move constructor. Transfers ownership.
- Parameters
-
obj The source instance (nulled after move).
Definition at line 68 of file ErasedUnique.ixx.
Reference ErasedUnique.
Public Destructor
~ErasedUnique()
| inline |
Destructor. Destroys the owned object if present.
Definition at line 93 of file ErasedUnique.ixx.
Reference reset.
Public Operators
operator=()
| inline noexcept |
Move assignment. Transfers ownership after releasing current.
- Parameters
-
obj The source instance (nulled after move).
- Returns
Reference to this instance.
Definition at line 80 of file ErasedUnique.ixx.
References destroy, ErasedUnique, ptr and reset.
Public Member Attributes
destroy
|
ptr
The documentation for this struct was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.