HDK
|
#include <pointerAndBits.h>
Public Member Functions | |
constexpr | TfPointerAndBits () noexcept |
constexpr | TfPointerAndBits (T *p, uintptr_t bits=0) noexcept |
Constructor. Set the pointer to p, and the bits to bits. More... | |
constexpr uintptr_t | GetMaxValue () const |
constexpr uintptr_t | GetNumBitsValues () const |
TfPointerAndBits & | operator= (T *ptr) noexcept |
Assignment. Leaves bits unmodified. More... | |
constexpr T * | operator-> () const noexcept |
Indirection. More... | |
constexpr T & | operator* () const noexcept |
Dereference. More... | |
template<class Integral > | |
constexpr Integral | BitsAs () const noexcept |
Retrieve the stored bits as the integral type Integral. More... | |
template<class Integral > | |
void | SetBits (Integral val) noexcept |
Set the stored bits. No static range checking is performed. More... | |
void | Set (T *ptr) noexcept |
Set the pointer value to ptr. More... | |
template<class Integral > | |
void | Set (T *ptr, Integral val) noexcept |
Set the pointer value to ptr and the bits to val. More... | |
constexpr T * | Get () const noexcept |
Retrieve the pointer. More... | |
constexpr uintptr_t | GetLiteral () const noexcept |
void | Swap (TfPointerAndBits &other) noexcept |
Swap this PointerAndBits with other. More... | |
This class stores a T * and a small integer in the space of a T *. The number of bits possible to store depends on the alignment of T. The number of distinct values representable by the bits and the maximal value are exposed via the compile time constants NumBitsValues and MaxValue, respectively.
The bits may be set and retrieved as any integral type. The pointer value and the bits value may be set and retrieved independently.
Definition at line 53 of file pointerAndBits.h.
|
inlinenoexcept |
Constructor. Pointer is initialized to null, bits are initialized to zero.
Definition at line 81 of file pointerAndBits.h.
|
inlineexplicitnoexcept |
Constructor. Set the pointer to p, and the bits to bits.
Definition at line 87 of file pointerAndBits.h.
|
inlinenoexcept |
Retrieve the stored bits as the integral type Integral.
Definition at line 120 of file pointerAndBits.h.
|
inlinenoexcept |
Retrieve the pointer.
Definition at line 147 of file pointerAndBits.h.
|
inlinenoexcept |
Retrieve the raw underlying value. This can be useful for doing literal equality checks between two instances. The only guarantees are that this has the same bit pattern as the pointer value if the bits are 0, and will compare equal to another instance when both have identical pointer and bits values.
Definition at line 156 of file pointerAndBits.h.
|
inline |
Definition at line 94 of file pointerAndBits.h.
|
inline |
Definition at line 98 of file pointerAndBits.h.
|
inlinenoexcept |
Dereference.
Definition at line 114 of file pointerAndBits.h.
|
inlinenoexcept |
Indirection.
Definition at line 109 of file pointerAndBits.h.
|
inlinenoexcept |
Assignment. Leaves bits unmodified.
Definition at line 103 of file pointerAndBits.h.
|
inlinenoexcept |
Set the pointer value to ptr.
Definition at line 136 of file pointerAndBits.h.
|
inlinenoexcept |
Set the pointer value to ptr and the bits to val.
Definition at line 142 of file pointerAndBits.h.
|
inlinenoexcept |
Set the stored bits. No static range checking is performed.
Definition at line 131 of file pointerAndBits.h.
|
inlinenoexcept |
Swap this PointerAndBits with other.
Definition at line 161 of file pointerAndBits.h.