QExplicitlySharedDataPointer Class
template <typename T> class QExplicitlySharedDataPointer
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object. More…
| Header | #include <QExplicitlySharedDataPointer> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
List of all members, including inherited members
Public Functions
| QExplicitlySharedDataPointer() | |
| QExplicitlySharedDataPointer(T *data) | |
| QExplicitlySharedDataPointer(const QExplicitlySharedDataPointer &o) | |
| QExplicitlySharedDataPointer & | operator=(const QExplicitlySharedDataPointer &o) |
| ~QExplicitlySharedDataPointer() | |
| void | detach() |
| T & | operator*() const |
| T * | operator->() const |
| T * | data() const |
| T * | get() const |
| operator bool() const | |
| bool | operator!() const |
| const T * | constData() const |
| QExplicitlySharedDataPointer(QAdoptSharedDataTag, T *data) | |
| QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o) | |
| QExplicitlySharedDataPointer & | operator=(QExplicitlySharedDataPointer &&o) |
| void | reset(T *ptr = nullptr) |
| void | swap(QExplicitlySharedDataPointer &other) |
| T * | take() |
Detailed Description
QExplicitlySharedDataPointer<T> shares a QSharedData-derived object like QSharedDataPointer does, but never detaches implicitly: modifying the data through any pointer modifies it for all of them. Call detach() to make a private copy explicitly.
See also QSharedData and QSharedDataPointer.
Differences from Qt
The conversion to bool is implicit.
Member Function Documentation
QExplicitlySharedDataPointer::QExplicitlySharedDataPointer()
Constructs a null pointer.
QExplicitlySharedDataPointer::QExplicitlySharedDataPointer(T *data)
Constructs a pointer that shares data and increments its reference count. A null data gives a null pointer.
QExplicitlySharedDataPointer::QExplicitlySharedDataPointer(const QExplicitlySharedDataPointer &o)
Constructs a copy of o that shares its data and increments the reference count.
QExplicitlySharedDataPointer::QExplicitlySharedDataPointer(QAdoptSharedDataTag, T *data)
Constructs a pointer that takes over a reference to data that the caller already counted, without incrementing the reference count.
This function was introduced in 6.0.
QExplicitlySharedDataPointer::QExplicitlySharedDataPointer(QExplicitlySharedDataPointer &&o)
Constructs a pointer that takes over the object of o, leaving o null.
QExplicitlySharedDataPointer::~QExplicitlySharedDataPointer()
Destroys the pointer, decrementing the reference count and deleting the data if this was the last reference.
const T * QExplicitlySharedDataPointer::constData() const
Returns a const pointer to the shared object, or nullptr.
T * QExplicitlySharedDataPointer::data() const
Returns a pointer to the data without detaching.
void QExplicitlySharedDataPointer::detach()
Detaches from shared data. If the data is shared with another pointer, it is copied and this pointer refers to the copy. Does nothing for a null pointer.
T * QExplicitlySharedDataPointer::get() const
Returns a pointer to the data without detaching. This is the same as data().
This function was introduced in 6.0.
QExplicitlySharedDataPointer::operator bool() const
Returns true if the pointer is not null; otherwise returns false.
bool QExplicitlySharedDataPointer::operator!() const
Returns true if the pointer is null.
T & QExplicitlySharedDataPointer::operator*() const
Returns a reference to the data without detaching.
T * QExplicitlySharedDataPointer::operator->() const
Returns a pointer to the data without detaching.
QExplicitlySharedDataPointer & QExplicitlySharedDataPointer::operator=(const QExplicitlySharedDataPointer &o)
Assigns o to this pointer, which then shares the data of o, and returns a reference to this pointer.
QExplicitlySharedDataPointer & QExplicitlySharedDataPointer::operator=(QExplicitlySharedDataPointer &&o)
Takes over the object of o, releasing the current one, and returns a reference to this pointer.
void QExplicitlySharedDataPointer::reset(T *ptr = nullptr)
Points to ptr instead, releasing the current object.
void QExplicitlySharedDataPointer::swap(QExplicitlySharedDataPointer &other)
Swaps this pointer with other.
T * QExplicitlySharedDataPointer::take()
Returns the shared object and makes this pointer null, without changing the reference count.
This function was introduced in 6.0.