16#ifndef RANS_INTERNAL_CONTAINERS_BITPTR_H_
17#define RANS_INTERNAL_CONTAINERS_BITPTR_H_
23#include <fmt/format.h>
35 inline constexpr BitPtr() noexcept {};
42 assert(
reinterpret_cast<intptr_t>(
ptr) %
sizeof(T) == 0);
54 return mBitAdr % utils::toBits<T>();
58 inline constexpr T*
toPtr() const noexcept
63 if constexpr (
sizeof(T) > 1) {
64 byteAdress -= getOffset<T>();
66 return reinterpret_cast<T*
>(byteAdress >> ToBytesShift);
69 inline constexpr explicit operator intptr_t() const noexcept
75 inline constexpr explicit operator T*()
const noexcept
109 mBitAdr += bitOffset;
115 auto tmp = *
const_cast<BitPtr*
>(
this);
116 return tmp += bitOffset;
121 mBitAdr -= bitOffset;
127 auto tmp = *
const_cast<BitPtr*
>(
this);
128 return tmp -= bitOffset;
133 return this->mBitAdr -
other.mBitAdr;
138 return bitPtr + bitOffset;
157 inline static constexpr intptr_t ToBytesShift = 3;
common helper classes and functions
constexpr BitPtr() noexcept
constexpr intptr_t getOffset() const noexcept
constexpr BitPtr(intptr_t bitAdr) noexcept
constexpr BitPtr operator-(intptr_t bitOffset) const noexcept
friend BitPtr operator+(intptr_t bitOffset, const BitPtr &bitPtr)
constexpr const bitAddress_type & getBitAddress() const noexcept
constexpr BitPtr & operator--() noexcept
constexpr BitPtr operator+(intptr_t bitOffset) const noexcept
constexpr BitPtr & operator+=(intptr_t bitOffset) noexcept
constexpr BitPtr operator--(int) noexcept
constexpr bool operator>(const BitPtr &other) const noexcept
constexpr bitAddress_type & getBitAddress() noexcept
constexpr T * toPtr() const noexcept
constexpr BitPtr(const T *ptr, intptr_t offset=0) noexcept
constexpr bool operator!=(const BitPtr &other) const noexcept
constexpr bool operator>=(const BitPtr &other) const noexcept
constexpr BitPtr & operator-=(intptr_t bitOffset) noexcept
constexpr intptr_t operator-(const BitPtr &other) const noexcept
constexpr bool operator<(const BitPtr &other) const noexcept
constexpr bool operator==(const BitPtr &other) const noexcept
constexpr bool operator<=(const BitPtr &other) const noexcept
constexpr BitPtr & operator++() noexcept
friend void swap(BitPtr &first, BitPtr &second)
constexpr BitPtr operator++(int) noexcept
constexpr uintptr_t adr2Bits(T *address) noexcept
std::ostream & operator<<(std::ostream &os, const BitPtr bitPtr)
VectorOfTObjectPtrs other