summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qscopedpointer.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-05-22 15:15:19 +0200
committerMarc Mutz <marc.mutz@kdab.com>2017-06-06 07:30:30 +0000
commit1e8e79d71e9e1a7ea1aa17dc16f3c17fd2e22eed (patch)
tree63eddbb7683d8a1bda972885a467c0210166bdd8 /src/corelib/tools/qscopedpointer.h
parent04eba7b538072e2811f074bf66fd41f27c90b35c (diff)
QScopedArrayPointer: document the most important ctor
The ctor that everyone would want to use was marked as \internal, probably because of the SFINAE expression appearing in its signature. Move the SFINAE to the template argument list, which QDoc hides from the user, and drop the \internal. While at it, drop the home-grown std::is_same re-implementation and use the real deal. Change-Id: Ia357fe65f94e10ac9eeccb3490aa8b3e68114cbb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/tools/qscopedpointer.h')
-rw-r--r--src/corelib/tools/qscopedpointer.h13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index 92d7df6e5d..141a3f8c70 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -215,21 +215,16 @@ template <class T, class Cleanup>
inline void swap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2) Q_DECL_NOTHROW
{ p1.swap(p2); }
-
-namespace QtPrivate {
- template <typename X, typename Y> struct QScopedArrayEnsureSameType;
- template <typename X> struct QScopedArrayEnsureSameType<X,X> { typedef X* Type; };
- template <typename X> struct QScopedArrayEnsureSameType<const X, X> { typedef X* Type; };
-}
-
template <typename T, typename Cleanup = QScopedPointerArrayDeleter<T> >
class QScopedArrayPointer : public QScopedPointer<T, Cleanup>
{
+ template <typename Ptr>
+ using if_same_type = typename std::enable_if<std::is_same<typename std::remove_cv<T>::type, Ptr>::value, bool>::type;
public:
inline QScopedArrayPointer() : QScopedPointer<T, Cleanup>(Q_NULLPTR) {}
- template <typename D>
- explicit inline QScopedArrayPointer(D *p, typename QtPrivate::QScopedArrayEnsureSameType<T,D>::Type = Q_NULLPTR)
+ template <typename D, if_same_type<D> = true>
+ explicit QScopedArrayPointer(D *p)
: QScopedPointer<T, Cleanup>(p)
{
}