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>
bb10
Marc Mutz 2017-05-22 15:15:19 +02:00
parent 04eba7b538
commit 1e8e79d71e
2 changed files with 7 additions and 12 deletions

View File

@ -303,10 +303,10 @@ QT_BEGIN_NAMESPACE
*/
/*!
\fn QScopedArrayPointer::QScopedArrayPointer(D * p, QtPrivate::QScopedArrayEnsureSameType<T, D>::Type = 0)
\internal
\fn QScopedArrayPointer::QScopedArrayPointer(D * p)
Constructs a QScopedArrayPointer and stores the array of objects.
Constructs a QScopedArrayPointer and stores the array of objects
pointed to by \a p.
*/
/*!

View File

@ -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)
{
}