5#ifndef QTAGGEDPOINTER_H
6#define QTAGGEDPOINTER_H
8#include <QtCore/qglobal.h>
9#include <QtCore/qalgorithms.h>
10#include <QtCore/qmath.h>
11#include <QtCore/qtypeinfo.h>
22 static_assert((alignment & (alignment - 1)) == 0,
23 "Alignment of template parameter must be power of two");
25 static constexpr quint8 tagBits = quint8(qCountTrailingZeroBits(alignment));
26 static_assert(tagBits > 0,
27 "Alignment of template parameter does not allow any tags");
29 static constexpr size_t tagSize = qNextPowerOfTwo(nextByteSize(tagBits));
31 "Alignment of template parameter allows tags masking away pointer");
57 "QTaggedPointer<T, Tag>::setTag",
"Tag is larger than allowed by number of available tag bits");
110 "QTaggedPointer<T, Tag>::setTag",
111 "Tag is larger than allowed by number of available tag bits");
180template <
typename T,
typename Tag>
182{
return qHash(p.data(), seed); }
184template <
typename T,
typename Tag>
Type * operator->() const noexcept
static constexpr quintptr pointerMask()
static constexpr quintptr tagMask()
operator bool() const noexcept
Type & operator*() const noexcept
constexpr quint8 nextByteSize(quint8 bits)
constexpr std::size_t qHash(QTaggedPointer< T, Tag > p, std::size_t seed=0) noexcept
static constexpr size_t tagSize
static constexpr size_t alignment
static constexpr quint8 tagBits