9#ifndef INCLUDED_BDLB_NULLABLEALLOCATEDVALUE_POINTERBITSPAIR
10#define INCLUDED_BDLB_NULLABLEALLOCATEDVALUE_POINTERBITSPAIR
64#include <bslscm_version.h>
75#include <bsl_cstddef.h>
98template <
class t_TYPE,
unsigned t_NUM_BITS>
106 enum { k_Mask = (1 << t_NUM_BITS ) - 1 };
181template <
class t_TYPE,
unsigned t_NUM_BITS>
190template <
class t_TYPE,
unsigned t_NUM_BITS>
197template <
class t_TYPE,
unsigned t_NUM_BITS>
214template <
class t_TYPE,
unsigned t_NUM_BITS>
222 static_cast<bsl::size_t
>(k_Mask) <
226template <
class t_TYPE,
unsigned t_NUM_BITS>
230: d_Value(reinterpret_cast<uintptr_t>(ptr))
234 d_Value |= (flags & k_Mask);
238template <
class t_TYPE,
unsigned t_NUM_BITS>
243 return d_Value == other.d_Value;
247template <
class t_TYPE,
unsigned t_NUM_BITS>
252 return reinterpret_cast<t_TYPE *
>(d_Value & ~uintptr_t(k_Mask));
255template <
class t_TYPE,
unsigned t_NUM_BITS>
261 return 0 != (d_Value & (1 << idx));
265template <
class t_TYPE,
unsigned t_NUM_BITS>
272 const uintptr_t mask = 1U << idx;
276template <
class t_TYPE,
unsigned t_NUM_BITS>
283 const uintptr_t mask = 1U << idx;
287template <
class t_TYPE,
unsigned t_NUM_BITS>
292 const uintptr_t value =
reinterpret_cast<uintptr_t
>(new_ptr);
296 d_Value = value | (d_Value & k_Mask);
299template <
class t_TYPE,
unsigned t_NUM_BITS>
309template <
class t_TYPE,
unsigned t_NUM_BITS>
315 return lhs.
equal(rhs);
318template <
class t_TYPE,
unsigned t_NUM_BITS>
324 return !(lhs == rhs);
327template <
class t_TYPE,
unsigned t_NUM_BITS>
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:99
NullableAllocatedValue_PointerBitsPair(const NullableAllocatedValue_PointerBitsPair &original)=default
NullableAllocatedValue_PointerBitsPair & operator=(const NullableAllocatedValue_PointerBitsPair &rhs)=default
~NullableAllocatedValue_PointerBitsPair()=default
Destroy this object.
static void swap(T *a, T *b)
Definition bslalg_swaputil.h:194
void setFlag(unsigned idx)
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:279
void clearFlag(unsigned idx)
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:268
NullableAllocatedValue_PointerBitsPair()
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:217
bool readFlag(unsigned idx) const
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:258
t_TYPE * getPointer() const
Return the held pointer.
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:250
bool equal(const NullableAllocatedValue_PointerBitsPair &other) const
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:240
void swap(NullableAllocatedValue_PointerBitsPair &other)
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:301
NullableAllocatedValue_PointerBitsPair(t_TYPE *ptr, unsigned flags=0)
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:229
void setPointer(t_TYPE *new_ptr)
Set the held pointer to the value of the specified new_ptr.
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:290
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLS_ASSERT_OPT(X)
Definition bsls_assert.h:1856
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlb_algorithmworkaroundutil.h:74
bool operator!=(const BigEndianInt16 &lhs, const BigEndianInt16 &rhs)
void swap(NullableAllocatedValue< TYPE > &a, NullableAllocatedValue< TYPE > &b)
bool operator==(const BigEndianInt16 &lhs, const BigEndianInt16 &rhs)
Definition bsls_alignmentfromtype.h:376