4#ifndef QTAGGEDPOINTER_H
5#define QTAGGEDPOINTER_H
7#include <QtCore/qglobal.h>
8#include <QtCore/qalgorithms.h>
9#include <QtCore/qmath.h>
10#include <QtCore/qtypeinfo.h>
21 static_assert((alignment & (alignment - 1)) == 0,
22 "Alignment of template parameter must be power of two");
24 static constexpr quint8 tagBits = quint8(qCountTrailingZeroBits(alignment));
25 static_assert(tagBits > 0,
26 "Alignment of template parameter does not allow any tags");
30 "Alignment of template parameter allows tags masking away pointer");
56 "QTaggedPointer<T, Tag>::setTag",
"Tag is larger than allowed by number of available tag bits");
109 "QTaggedPointer<T, Tag>::setTag",
110 "Tag is larger than allowed by number of available tag bits");
179template <
typename T,
typename Tag>
181{
return qHash(p.data(), seed); }
183template <
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