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 };
185template <
class t_TYPE,
unsigned t_NUM_BITS>
194template <
class t_TYPE,
unsigned t_NUM_BITS>
201template <
class t_TYPE,
unsigned t_NUM_BITS>
218template <
class t_TYPE,
unsigned t_NUM_BITS>
226 static_cast<bsl::size_t
>(k_Mask) <
230template <
class t_TYPE,
unsigned t_NUM_BITS>
234: d_Value(reinterpret_cast<uintptr_t>(ptr))
238 d_Value |= (flags & k_Mask);
242template <
class t_TYPE,
unsigned t_NUM_BITS>
247 return d_Value == other.d_Value;
251template <
class t_TYPE,
unsigned t_NUM_BITS>
256 return reinterpret_cast<t_TYPE *
>(d_Value & ~uintptr_t(k_Mask));
259template <
class t_TYPE,
unsigned t_NUM_BITS>
265 return 0 != (d_Value & (1 << idx));
269template <
class t_TYPE,
unsigned t_NUM_BITS>
276 const uintptr_t mask = 1U << idx;
280template <
class t_TYPE,
unsigned t_NUM_BITS>
287 const uintptr_t mask = 1U << idx;
291template <
class t_TYPE,
unsigned t_NUM_BITS>
296 const uintptr_t value =
reinterpret_cast<uintptr_t
>(new_ptr);
300 d_Value = value | (d_Value & k_Mask);
303template <
class t_TYPE,
unsigned t_NUM_BITS>
313template <
class t_TYPE,
unsigned t_NUM_BITS>
319 return lhs.equal(rhs);
322template <
class t_TYPE,
unsigned t_NUM_BITS>
328 return !(lhs == rhs);
331template <
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:182
void setFlag(unsigned idx)
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:283
void clearFlag(unsigned idx)
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:272
NullableAllocatedValue_PointerBitsPair()
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:221
bool readFlag(unsigned idx) const
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:262
t_TYPE * getPointer() const
Return the held pointer.
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:254
bool equal(const NullableAllocatedValue_PointerBitsPair &other) const
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:244
void swap(NullableAllocatedValue_PointerBitsPair &other)
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:305
NullableAllocatedValue_PointerBitsPair(t_TYPE *ptr, unsigned flags=0)
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:233
void setPointer(t_TYPE *new_ptr)
Set the held pointer to the value of the specified new_ptr.
Definition bdlb_nullableallocatedvalue_pointerbitspair.h:294
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:231
#define BSLS_ASSERT_OPT(X)
Definition bsls_assert.h:2045
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
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:378