26 void operator()(QVariant::PrivateShared *p)
const
27 { QVariant::PrivateShared::free(p); }
31 std::unique_ptr<QVariant::PrivateShared, Deleter> ptr;
32 ptr.reset(QVariant::PrivateShared::create(size, align));
39 auto ptr = customConstructSharedImpl(size, align);
40 construct(ptr->data());
44inline int QVariant::PrivateShared::computeOffset(PrivateShared *ps, size_t align)
46 return int(((quintptr(ps) +
sizeof(PrivateShared) + align - 1) & ~(align - 1)) - quintptr(ps));
49inline size_t QVariant::PrivateShared::computeAllocationSize(size_t size, size_t align)
51 size +=
sizeof(PrivateShared);
52 if (align >
sizeof(PrivateShared)) {
57 size += align -
sizeof(PrivateShared);
62inline QVariant::PrivateShared *QVariant::PrivateShared::create(size_t size, size_t align)
64 size = computeAllocationSize(size, align);
65 void *data = operator
new(size);
66 auto *ps =
new (data) QVariant::PrivateShared();
67 ps->offset = computeOffset(ps, align);
71inline void QVariant::PrivateShared::free(PrivateShared *p)
77inline QVariant::Private::Private(
const QtPrivate::QMetaTypeInterface *iface)
noexcept
78 : is_shared(
false), is_null(
false), packedType(quintptr(iface) >> 2)
80 Q_ASSERT((quintptr(iface) & 0x3) == 0);
84QVariant::Private::Private(std::in_place_t, TT &&t)
85 : is_shared{!CanUseInternalSpace<q20::remove_cvref_t<TT>>},
86 is_null{std::is_null_pointer_v<std::remove_reference_t<TT>>}
88 using T = q20::remove_cvref_t<TT>;
90 constexpr bool isNothrowQVariantConstructible =
noexcept(QVariant{std::forward<TT>(t)});
91 constexpr bool isNothrowConstructible = std::is_nothrow_constructible_v<T, TT>;
92 constexpr bool isNothrowAssignable = std::is_nothrow_assignable_v<T&, TT>;
94 const QtPrivate::QMetaTypeInterface *iface = QtPrivate::qMetaTypeInterfaceForType<T>();
95 Q_ASSERT((quintptr(iface) & 0x3) == 0);
96 packedType = quintptr(iface) >> 2;
98 if constexpr (CanUseInternalSpace<T>) {
99 static_assert(isNothrowQVariantConstructible == isNothrowConstructible);
100 static_assert(isNothrowQVariantConstructible == isNothrowAssignable);
101 new (data.data) T(std::forward<TT>(t));
103 static_assert(!isNothrowQVariantConstructible);
104 data.shared = customConstructShared(
sizeof(T),
alignof(T), [&t](
void *where) {
105 new (where) T(std::forward<TT>(t));
QDataStream & operator>>(QDataStream &s, QVariant &p)
\keyword 16-bit Floating Point Support\inmodule QtCore \inheaderfile QFloat16
Combined button and popup list for selecting options.
constexpr int Qt6ToQt5GuiTypeDelta
static bool qIsFloatingPoint(uint tp)
static QPartialOrdering numericCompare(const QVariant::Private *d1, const QVariant::Private *d2)
constexpr int Qt5QQuaternion
static bool qIsNumericType(uint tp)
static bool canBeNumericallyCompared(const QtPrivate::QMetaTypeInterface *iface1, const QtPrivate::QMetaTypeInterface *iface2)
constexpr int Qt5KeySequence
static QPartialOrdering integralCompare(uint promotedType, const QVariant::Private *d1, const QVariant::Private *d2)
static const ushort mapIdFromQt3ToCurrent[MapFromThreeCount]
constexpr int Qt5LastCoreType
T qNumVariantToHelper(const QVariant::Private &d, bool *ok)
constexpr int Qt5FirstGuiType
static bool qvCanConvertMetaObject(QMetaType fromType, QMetaType toType)
constexpr int Qt5LastGuiType
static int numericTypePromotion(const QtPrivate::QMetaTypeInterface *iface1, const QtPrivate::QMetaTypeInterface *iface2)
constexpr int Qt5SizePolicy
#define MAKE_CTOR_BY_VALUE(...)
#define MAKE_CTOR_BY_REF(...)
constexpr int Qt5UserType
static QPartialOrdering pointerCompare(const QVariant::Private *d1, const QVariant::Private *d2)
QT_BEGIN_NAMESPACE auto customConstructSharedImpl(size_t size, size_t align)
static QVariant::PrivateShared * customConstructShared(size_t size, size_t align, F &&construct)