|
xenium
|
A pointer with an embedded mark/tag value. More...
#include <marked_ptr.hpp>
Public Member Functions | |
| marked_ptr (T *p=nullptr, uintptr_t mark=0) noexcept | |
| Construct a marked_ptr with an optional mark value. More... | |
| void | reset () noexcept |
Reset the pointer to nullptr and the mark to 0. | |
| uintptr_t | mark () const noexcept |
| Get the mark value. | |
| T * | get () const noexcept |
| Get underlying pointer (with mark bits stripped off). | |
| operator bool () const noexcept | |
True if get() != nullptr || mark() != 0 | |
| T * | operator-> () const noexcept |
| Get pointer with mark bits stripped off. | |
| T & | operator* () const noexcept |
| Get reference to target of pointer. | |
A pointer with an embedded mark/tag value.
Acts like a pointer, but has an embeded mark/tag value with MarkBits bits. On most systems pointers are only 48-bit, leaving the 16 topmost bits clear. Therefore, the mark value is usually embeded in these top-most bits. For mark mark values that exceed MaxUpperMarkBits bits the remaining bits are embedded in the lowest bits, but this requires the pointer to be aligned properly.
| T | |
| MarkBits | the number of bits used for the mark value |
| MaxUpperMarkBits | the max number of bits to be used (defaults to 16) |
|
inlinenoexcept |
Construct a marked_ptr with an optional mark value.
The mark value is automatically trimmed to MarkBits bits.
1.8.17