|
| Pointer ()=default |
| Default construct an empty instance.
|
|
template<typename DeleterFunction > |
| Pointer (T *ptr, DeleterFunction deleter) |
| Constructs the instance from the given pointer and deleter function.
|
|
| Pointer (Pointer &&other) noexcept |
| Move construct an instance from other.
|
|
Pointer & | operator= (Pointer &&other) noexcept |
| Move assign an instance from other.
|
|
| Pointer (Pointer &other)=delete |
| Copy construction disabled.
|
|
Pointer & | operator= (Pointer &other)=delete |
| Copy assignment disabled.
|
|
| ~Pointer () |
| Destructs the instance, invoking cleanup logic if the instance is non-empty.
|
|
| operator bool () const |
| Boolean conversion operator.
|
|
T * | get () |
| Gets the raw pointer stored in this instance.
|
|
const T * | get () const |
| Gets the raw pointer stored in this instance.
|
|
T * | operator-> () |
| Access the raw pointer in this instance.
|
|
const T * | operator-> () const |
| Access the raw pointer in this instance.
|
|
template<typename T>
struct Cogs::Pointer< T >
Provides scoped storage for a raw pointer and corresponding deletion logic.
Typically used where raw new/delete is not applicable to store destruction logic along the raw pointer, instead of relying on manual cleanup code.
The ownership may be moved to another instance to facilitate relocating Pointer instances.
Example:
Resource * r = pool.allocate();
{
auto p =
makePointer(r, [&pool](Resource * r){ pool.deallocate(); });
...
if (p) {
}
}
Pointer< T > makePointer(T *t, DeleterFunction deleterFunc)
Construct a Pointer<T> instance from the given pointer and deleter function.
- Template Parameters
-
T | Type of raw pointer stored. |
Definition at line 65 of file Pointer.h.