4#ifndef QQMLREFCOUNT_P_H
5#define QQMLREFCOUNT_P_H
18#include <QtCore/qglobal.h>
19#include <QtCore/qatomic.h>
20#include <private/qv4global_p.h>
32 inline void addref()
const;
33 inline int count()
const;
71 inline bool isNull()
const {
return !o; }
75 explicit inline operator bool()
const {
return o !=
nullptr; }
76 inline T*
data()
const {
return o; }
80 inline T*
take() { T *
res = o; o =
nullptr;
return res; }
107template <
typename T,
typename ...Args>
110 static_assert(std::is_base_of_v<QQmlRefCount, T>);
123QQmlRefCount::~QQmlRefCount()
137 static_assert(std::is_base_of_v<QQmlRefCounted, T>,
138 "QQmlRefCounted<T> must be a base of T (CRTP)");
139 Q_ASSERT(refCount.loadRelaxed() > 0);
140 if (!refCount.deref())
141 delete static_cast<const T *
>(
this);
147 static_assert(std::is_final_v<T> || std::has_virtual_destructor_v<T>,
148 "T must either be marked final or have a virtual dtor, "
149 "lest release() runs into UB.");
T loadRelaxed() const noexcept
friend bool operator==(const QQmlRefPointer &a, const QQmlRefPointer &b)
QQmlRefPointer< T > & operator=(const QQmlRefPointer< T > &o)
QQmlRefPointer< T > & operator=(QQmlRefPointer< T > &&o) noexcept
QQmlRefPointer< T > & adopt(T *)
Takes ownership of other.
friend bool operator!=(const QQmlRefPointer &a, const QQmlRefPointer &b)
Q_NODISCARD_CTOR QQmlRefPointer() noexcept
QQmlRefPointer< T > makeRefPointer(Args &&... args)
Combined button and popup list for selecting options.
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept
#define Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS)