Support std::unique_ptr and others in Q_DECLARE_PRIVATE
Use ptr.operator->() instead of ptr.data() for getting the raw pointer. [ChangeLog][QtCore][QtGlobal] Q_DECLARE_PRIVATE can now be used with std::unique_ptr and other smart pointer types. Change-Id: I7f3f698d7bac477f2185837681e366057d292588 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
c2ccb48560
commit
98ef4239a6
@ -1034,8 +1034,8 @@ for (auto _container_ = QtPrivate::qMakeForeachContainer(container); \
|
||||
# endif
|
||||
#endif
|
||||
|
||||
template <typename T> static inline T *qGetPtrHelper(T *ptr) { return ptr; }
|
||||
template <typename Wrapper> static inline typename Wrapper::pointer qGetPtrHelper(const Wrapper &p) { return p.data(); }
|
||||
template <typename T> inline T *qGetPtrHelper(T *ptr) { return ptr; }
|
||||
template <typename Ptr> inline auto qGetPtrHelper(const Ptr &ptr) -> decltype(ptr.operator->()) { return ptr.operator->(); }
|
||||
|
||||
#define Q_DECLARE_PRIVATE(Class) \
|
||||
inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr)); } \
|
||||
|
Loading…
Reference in New Issue
Block a user