tlx
|
Provides reference counting abilities for use with CountingPtr. More...
#include <counting_ptr.hpp>
Public Member Functions | |
ReferenceCounter () noexcept | |
new objects have zero reference count More... | |
ReferenceCounter (const ReferenceCounter &) noexcept | |
coping still creates a new object with zero reference count More... | |
ReferenceCounter & | operator= (const ReferenceCounter &) noexcept |
assignment operator, leaves pointers unchanged More... | |
~ReferenceCounter () | |
void | inc_reference () const noexcept |
Call whenever setting a pointer to the object. More... | |
bool | dec_reference () const noexcept |
Call whenever resetting (i.e. More... | |
bool | unique () const noexcept |
Test if the ReferenceCounter is referenced by only one CountingPtr. More... | |
size_t | reference_count () const noexcept |
Return the number of references to this object (for debugging) More... | |
Private Attributes | |
std::atomic< size_t > | reference_count_ |
the reference count is kept mutable for CountingPtr<const Type> to change the reference count. More... | |
Provides reference counting abilities for use with CountingPtr.
Use as superclass of the actual object, this adds a reference_count_ value. Then either use CountingPtr as pointer to manage references and deletion, or just do normal new and delete.
Definition at line 337 of file counting_ptr.hpp.
|
inlinenoexcept |
new objects have zero reference count
Definition at line 346 of file counting_ptr.hpp.
|
inlinenoexcept |
coping still creates a new object with zero reference count
Definition at line 350 of file counting_ptr.hpp.
|
inline |
Definition at line 359 of file counting_ptr.hpp.
|
inlinenoexcept |
Call whenever resetting (i.e.
overwriting) a pointer to the object. IMPORTANT: In case of self-assignment, call AFTER inc_reference().
Definition at line 374 of file counting_ptr.hpp.
|
inlinenoexcept |
Call whenever setting a pointer to the object.
Definition at line 364 of file counting_ptr.hpp.
|
inlinenoexcept |
assignment operator, leaves pointers unchanged
Definition at line 354 of file counting_ptr.hpp.
|
inlinenoexcept |
Return the number of references to this object (for debugging)
Definition at line 384 of file counting_ptr.hpp.
|
inlinenoexcept |
Test if the ReferenceCounter is referenced by only one CountingPtr.
Definition at line 380 of file counting_ptr.hpp.
|
mutableprivate |
the reference count is kept mutable for CountingPtr<const Type> to change the reference count.
Definition at line 342 of file counting_ptr.hpp.