Q(E)SDP: add get()

[ChangeLog][QtCore][QSharedDataPointer] Added get() for
STL compatibility.
[ChangeLog][QtCore][QExplicitlySharedDataPointer] Added get() for
STL compatibility.

Change-Id: I1acb3b4f4bd70842ed53f6437be10404b67d9909
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Giuseppe D'Angelo 2020-06-08 16:47:08 +02:00
parent 2a767ab4bb
commit d7c75ee005
2 changed files with 21 additions and 0 deletions

View File

@ -285,11 +285,23 @@ QT_BEGIN_NAMESPACE
\sa constData()
*/
/*! \fn template <class T> T* QSharedDataPointer<T>::get()
\since 6.0
Same as data(). This function is provided for STL compatibility.
*/
/*! \fn template <class T> const T* QSharedDataPointer<T>::data() const
Returns a pointer to the shared data object.
This function does \e not call detach().
*/
/*! \fn template <class T> const T* QSharedDataPointer<T>::get() const
\since 6.0
Same as data(). This function is provided for STL compatibility.
*/
/*! \fn template <class T> const T* QSharedDataPointer<T>::constData() const
Returns a const pointer to the shared data object.
This function does \e not call detach().
@ -457,6 +469,12 @@ QT_BEGIN_NAMESPACE
Returns a pointer to the shared data object.
*/
/*! \fn template <class T> T* QExplicitlySharedDataPointer<T>::get() const
\since 6.0
Same as data(). This function is provided for STL compatibility.
*/
/*! \fn template <class T> const T* QExplicitlySharedDataPointer<T>::constData() const
Returns a const pointer to the shared data object.

View File

@ -83,7 +83,9 @@ public:
inline operator T *() { detach(); return d; }
inline operator const T *() const { return d; }
inline T *data() { detach(); return d; }
inline T *get() { detach(); return d; }
inline const T *data() const { return d; }
inline const T *get() const { return d; }
inline const T *constData() const { return d; }
inline bool operator==(const QSharedDataPointer<T> &other) const { return d == other.d; }
@ -160,6 +162,7 @@ public:
inline T *operator->() { return d; }
inline T *operator->() const { return d; }
inline T *data() const { return d; }
inline T *get() const { return d; }
inline const T *constData() const { return d; }
inline T *take() { T *x = d; d = nullptr; return x; }