HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TfPointerAndBits< T > Class Template Reference

#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
 
TfPointerAndBitsoperator= (T *ptr) noexcept
 Assignment. Leaves bits unmodified. More...
 
constexpr Toperator-> () const noexcept
 Indirection. More...
 
constexpr Toperator* () 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 TGet () const noexcept
 Retrieve the pointer. More...
 
constexpr uintptr_t GetLiteral () const noexcept
 
void Swap (TfPointerAndBits &other) noexcept
 Swap this PointerAndBits with other. More...
 

Detailed Description

template<class T>
class TfPointerAndBits< T >

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.

Constructor & Destructor Documentation

template<class T>
constexpr TfPointerAndBits< T >::TfPointerAndBits ( )
inlinenoexcept

Constructor. Pointer is initialized to null, bits are initialized to zero.

Definition at line 81 of file pointerAndBits.h.

template<class T>
constexpr TfPointerAndBits< T >::TfPointerAndBits ( T p,
uintptr_t  bits = 0 
)
inlineexplicitnoexcept

Constructor. Set the pointer to p, and the bits to bits.

Definition at line 87 of file pointerAndBits.h.

Member Function Documentation

template<class T>
template<class Integral >
constexpr Integral TfPointerAndBits< T >::BitsAs ( ) const
inlinenoexcept

Retrieve the stored bits as the integral type Integral.

Definition at line 120 of file pointerAndBits.h.

template<class T>
constexpr T* TfPointerAndBits< T >::Get ( ) const
inlinenoexcept

Retrieve the pointer.

Definition at line 147 of file pointerAndBits.h.

template<class T>
constexpr uintptr_t TfPointerAndBits< T >::GetLiteral ( ) const
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.

template<class T>
constexpr uintptr_t TfPointerAndBits< T >::GetMaxValue ( ) const
inline

Definition at line 94 of file pointerAndBits.h.

template<class T>
constexpr uintptr_t TfPointerAndBits< T >::GetNumBitsValues ( ) const
inline

Definition at line 98 of file pointerAndBits.h.

template<class T>
constexpr T& TfPointerAndBits< T >::operator* ( ) const
inlinenoexcept

Dereference.

Definition at line 114 of file pointerAndBits.h.

template<class T>
constexpr T* TfPointerAndBits< T >::operator-> ( ) const
inlinenoexcept

Indirection.

Definition at line 109 of file pointerAndBits.h.

template<class T>
TfPointerAndBits& TfPointerAndBits< T >::operator= ( T ptr)
inlinenoexcept

Assignment. Leaves bits unmodified.

Definition at line 103 of file pointerAndBits.h.

template<class T>
void TfPointerAndBits< T >::Set ( T ptr)
inlinenoexcept

Set the pointer value to ptr.

Definition at line 136 of file pointerAndBits.h.

template<class T>
template<class Integral >
void TfPointerAndBits< T >::Set ( T ptr,
Integral  val 
)
inlinenoexcept

Set the pointer value to ptr and the bits to val.

Definition at line 142 of file pointerAndBits.h.

template<class T>
template<class Integral >
void TfPointerAndBits< T >::SetBits ( Integral  val)
inlinenoexcept

Set the stored bits. No static range checking is performed.

Definition at line 131 of file pointerAndBits.h.

template<class T>
void TfPointerAndBits< T >::Swap ( TfPointerAndBits< T > &  other)
inlinenoexcept

Swap this PointerAndBits with other.

Definition at line 161 of file pointerAndBits.h.


The documentation for this class was generated from the following file: