#include <packed_ptr.h>
Public Member Functions | |
constexpr | PackedPtr (T *ptr, uintptr_t packed_value) |
template<typename T2 , typename = std::enable_if_t<std::is_convertible_v<T2, T>>> | |
constexpr | PackedPtr (const PackedPtr< T2 > &other) |
template<typename T2 , typename = std::enable_if_t<std::is_convertible_v<T2, T>>> | |
constexpr PackedPtr & | operator= (const PackedPtr< T2 > &other) |
template<typename T2 , typename = std::enable_if_t<std::is_convertible_v<T2, T>>> | |
constexpr | PackedPtr (PackedPtr< T2 > &&other) |
template<typename T2 , typename = std::enable_if_t<std::is_convertible_v<T2, T>>> | |
constexpr PackedPtr & | operator= (PackedPtr< T2 > &&other) |
constexpr T & | operator* () const |
constexpr T * | operator-> () const |
constexpr T * | get () const |
Returns the pointer. | |
constexpr uintptr_t | packed_value () const |
Returns the packed_value packed into the unused bits of the pointer. | |
constexpr void | set (T *ptr) |
Sets the pointer without changing the packed value. | |
constexpr void | set_packed_value (uintptr_t packed_value) |
Static Public Member Functions | |
static constexpr size_t | NumBits () |
Pointer wrapper that can store extra data in otherwise unused bits.
Pointers to types that have an alignment of more than 1 will always have their least significant bit(s) set to zero. For example, if alignof(T)
is 8, than the 3 least significant bits are always 0. In certain contexts where overhead needs to be tightly constrained, reusing these bits and avoiding additional fields may be worth the performance and code size penalties that arise from masking values.
|
inlineconstexpr |
Packs a packed_value into the unused bits of the pointer.