template<typename T>
InPlaceWrapper struct
A wrapper class for in-place allocations that may not have a corresponding destructor. If a user has an existing allocation that is deserialized into, it may never be destructed as it gets copied or moved. This class encapsulates that allocation and ensures it is properly destroyed, or it explicitly requires transferOwnership
to be invoked, indicating that the user is now responsible for its destruction. This typically occurs when the user or system places the type in a managed pointer, such as a std::unique_ptr<T>
with a standard deleter.
Constructors, destructors, conversion operators
- InPlaceWrapper(T* inPlaceObject) explicit
- ~InPlaceWrapper()
- InPlaceWrapper(const InPlaceWrapper&) deleted
- InPlaceWrapper(InPlaceWrapper&& other) noexcept
Public functions
- auto operator=(const InPlaceWrapper&) -> InPlaceWrapper& deleted
- auto operator=(InPlaceWrapper&& other) -> InPlaceWrapper& noexcept
- auto operator->() -> T*
- auto operator->() const -> const T*
- auto operator*() -> T&
- auto operator*() const -> const T&
- auto transferOwnership() -> T*
- Tranfer the ownership out of this container. Now the responsbility of where it was transfered to destroy it.