24 template <
typename PtrT>
27 typedef typename std::remove_pointer<PtrT>::type T;
28 static constexpr
int FreeBits = log2(
alignof(T));
29 static auto getPointer(uintptr_t value)
31 return reinterpret_cast<PtrT
>(value);
74 return _value < rhs._value;
78 return _value <= rhs._value;
82 return _value == rhs._value;
86 return _value > rhs._value;
90 return _value >= rhs._value;
112 template <
typename PtrT,
133 set(PtrT ptr, IntT val)
135 ASSERTD(((uintptr_t)ptr & PtrMask) == (uintptr_t)ptr);
136 ASSERTD(((uintptr_t)val & IntMask) == (uintptr_t)(val));
137 _value = (uintptr_t)ptr | (uintptr_t)(((intptr_t)val << IntShift));
142 auto getPointer()
const 144 return PtrTraits::getPointer(_value & PtrMask);
150 ASSERTD(((uintptr_t)ptr & PtrMask) == (uintptr_t)ptr);
151 _value = (_value & IntMask) | (uintptr_t)ptr;
159 return (IntT)((_value >> IntShift) & IntMask);
165 ASSERTD(((uintptr_t)val & IntMask) == (uintptr_t)(val));
166 _value = (_value & PtrMask) | (uintptr_t)(((intptr_t)val << IntShift));
171 static constexpr
int IntShift = PtrTraits::FreeBits - IntBits;
172 static constexpr uintptr_t IntMask = (uintptr_t)(((intptr_t)1 << IntBits) - 1);
173 static constexpr uintptr_t PtrMask = ~(uintptr_t)(((intptr_t)1 << PtrTraits::FreeBits) - 1);
182 template <
typename PtrT,
int IntBits,
typename IntT,
typename PtrTraits>
186 return (lhs.getPointer() ==
nullptr);
189 template <
typename PtrT,
int IntBits,
typename IntT,
typename PtrTraits>
190 inline bool operator==(std::nullptr_t lhs,
193 return (rhs.getPointer() ==
nullptr);
196 template <
typename PtrT,
int IntBits,
typename IntT,
typename PtrTraits>
200 return (lhs.getPointer() !=
nullptr);
203 template <
typename PtrT,
int IntBits,
typename IntT,
typename PtrTraits>
204 inline bool operator!=(std::nullptr_t lhs,
207 return (rhs.getPointer() !=
nullptr);
Non-template base class for PointerIntPair.
void serialize(bool &b, Stream &stream, uint_t io, uint_t mode=ser_default)
Serialize a boolean.
default representation (via getSerializeMode())
unsigned int uint_t
Unsigned integer.
#define ABORT()
Immediately terminates the program.
void serialize(Stream &stream, uint_t io, uint_t mode=ser_default)
Don't try to serialize.
#define ASSERTD
Do an assertion in DEBUG mode only.