Control block for reference counting - type erased. More...
#include <memory.hpp>
Public Types | |
| using | destroy_fn_t = size_t(void const *) |
| Destroy function for ref counted object. | |
Public Attributes | |
| std::pmr::polymorphic_allocator | allocator |
| Initialize to 1 since creation implies a reference. | |
| destroy_fn_t * | destroy |
| std::atomic< int32_t > | strong_count = 1 |
| std::atomic< int32_t > | weak_count = 0 |
Control block for reference counting - type erased.
This structure manages the lifetime of reference-counted objects by tracking strong and weak references. It also stores the memory allocator and destroy function used to clean up the object when no more references exist.
| using atlas::memory::detail::ref_info::destroy_fn_t = size_t(void const*) |
Destroy function for ref counted object.
Always returns the total size of the object wrapped in a ref count object. Thus the size should normally be greater than sizeof(T). Expect sizeof(T) + sizeof(ref_info) and anything else the ref count object may contain.
If a nullptr is passed to the destroy function, it returns the object size but does not destroy the object.