35template <QObjectDerived T>
class QObjectUniquePtr
38 QObjectUniquePtr (T * ptr =
nullptr) : ptr_ (ptr) { }
40 ~QObjectUniquePtr () { reset (); }
42 Q_DISABLE_COPY (QObjectUniquePtr)
45 QObjectUniquePtr (QObjectUniquePtr &&other) noexcept : ptr_ (other.release ())
51 QObjectUniquePtr (QObjectUniquePtr<U> &&other)
noexcept
52 requires std::derived_from<U, T>
53 : ptr_ (other.release ())
56 QObjectUniquePtr &operator= (QObjectUniquePtr &&other)
noexcept
60 reset (other.release ());
66 QObjectUniquePtr &operator= (QObjectUniquePtr<U> &&other)
noexcept
67 requires std::derived_from<U, T>
71 reset (other.release ());
76 void reset (T * ptr =
nullptr)
95 T * get ()
const {
return ptr_; }
96 T * operator->()
const {
return ptr_; }
97 T &operator* ()
const {
return *ptr_; }
98 explicit operator bool ()
const {
return !ptr_.isNull (); }
100 bool operator== (std::nullptr_t)
const {
return ptr_.isNull (); }
103 explicit operator QPointer<T> ()
const {
return ptr_; }