An implementation detail for the type-specific templated cell pointers.
More...
#include <CellPtr.h>
|
|
| operator bool () const noexcept |
| |
|
void | reset () noexcept |
| |
|
auto | cmpPointers (const CellPtrBase &o) const noexcept |
| | This is exactly like the spaceship operator in C++20.
|
| |
| auto | cmpObjects (const CellPtrBase &o) const noexcept |
| | This is the spaceship operator acting on pointed-to objects.
|
| |
|
auto | cmpObjects (const Observed *o) const noexcept |
| | This is the spaceship operator acting on pointed-to objects.
|
| |
|
bool | IsNull () const |
| |
|
bool | HasOneObserved () const |
| |
|
bool | HasControlBlock () const |
| |
|
|
template<typename U > |
| static bool constexpr | is_pointer () |
| |
|
static size_t | GetLiveInstanceCount () noexcept |
| |
|
|
static int | CmpAddresses (const void *a, const void *b) noexcept |
| | A total order over two (possibly unrelated) addresses, usable with < 0 / == 0 / > 0. Compares them as unsigned integers rather than via pointer subtraction: see the GH #2208 comment on cmpObjects() below.
|
| |
An implementation detail for the type-specific templated cell pointers.
A CellPtrBase (and thus the derived CellPtr) can be in one of 3 states:
- Pointing to no object: its m_ptr is null.
- A sole pointer to an object: its m_ptr points to the Observed, and observed's m_ptr points back at this pointer.
- One of many pointers to the object: its m_ptr points to the Observed::ControlBlock, and the observed's m_ptr also points to the control block.
◆ base_reset()
| void CellPtrBase::base_reset |
( |
Observed * |
obj = nullptr | ) |
|
|
protectednoexcept |
Different objects must have control blocks that are either null or non-null but different.
◆ cmpObjects()
| auto CellPtrBase::cmpObjects |
( |
const CellPtrBase & |
o | ) |
const |
|
inlinenoexcept |
This is the spaceship operator acting on pointed-to objects.
GH #2208: this used to be a plain base_get() - o.base_get() pointer subtraction. That is undefined behavior for two pointers into unrelated objects, and in practice, on 32-bit architectures, it can silently produce the wrong sign: a signed ptrdiff_t subtraction of two addresses spread widely across the (much smaller) 32-bit address space can overflow and wrap around, which a 64-bit build's much sparser address space essentially never triggers. Comparing the two addresses as unsigned integers instead is well-defined on any architecture and gives the total order operator< (used via cmpObjects() < 0) actually needs.
The documentation for this class was generated from the following files: