QSharedPointer: clean up #ifdefs
We require Q_COMPILER_RVALUE_REFS and _VARIADIC_TEMPLATES since Qt 5.7, so remove the non-variadic version which anyway has zero test coverage. Also drop #include <utility>, as that is included from qglobal.h already, and drop QSKIP from test. Change-Id: I1fc7f7068eac80ad6fd85e1d8f6d33c5c7bb67db Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
ff57203b57
commit
2889ebc903
@ -67,10 +67,6 @@ QT_END_NAMESPACE
|
||||
#endif
|
||||
#include <QtCore/qhashfunctions.h>
|
||||
|
||||
#if defined(Q_COMPILER_RVALUE_REFS) && defined(Q_COMPILER_VARIADIC_TEMPLATES)
|
||||
# include <utility> // for std::forward
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
@ -428,7 +424,6 @@ public:
|
||||
|
||||
QWeakPointer<T> toWeakRef() const;
|
||||
|
||||
#if defined(Q_COMPILER_RVALUE_REFS) && defined(Q_COMPILER_VARIADIC_TEMPLATES)
|
||||
template <typename... Args>
|
||||
static QSharedPointer create(Args && ...arguments)
|
||||
{
|
||||
@ -450,49 +445,6 @@ public:
|
||||
result.enableSharedFromThis(result.data());
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
static inline QSharedPointer create()
|
||||
{
|
||||
typedef QtSharedPointer::ExternalRefCountWithContiguousData<T> Private;
|
||||
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
|
||||
typename Private::DestroyerFn destroy = &Private::safetyCheckDeleter;
|
||||
# else
|
||||
typename Private::DestroyerFn destroy = &Private::deleter;
|
||||
# endif
|
||||
QSharedPointer result(Qt::Uninitialized);
|
||||
result.d = Private::create(&result.value, destroy);
|
||||
|
||||
// now initialize the data
|
||||
new (result.data()) T();
|
||||
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
|
||||
internalSafetyCheckAdd(result.d, result.value);
|
||||
# endif
|
||||
result.d->setQObjectShared(result.value, true);
|
||||
result.enableSharedFromThis(result.data());
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename Arg>
|
||||
static inline QSharedPointer create(const Arg &arg)
|
||||
{
|
||||
typedef QtSharedPointer::ExternalRefCountWithContiguousData<T> Private;
|
||||
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
|
||||
typename Private::DestroyerFn destroy = &Private::safetyCheckDeleter;
|
||||
# else
|
||||
typename Private::DestroyerFn destroy = &Private::deleter;
|
||||
# endif
|
||||
QSharedPointer result(Qt::Uninitialized);
|
||||
result.d = Private::create(&result.value, destroy);
|
||||
|
||||
// now initialize the data
|
||||
new (result.data()) T(arg);
|
||||
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
|
||||
internalSafetyCheckAdd(result.d, result.value);
|
||||
# endif
|
||||
result.d->setQObjectShared(result.value, true);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
explicit QSharedPointer(Qt::Initialization) {}
|
||||
|
@ -1738,9 +1738,6 @@ void tst_QSharedPointer::creating()
|
||||
|
||||
void tst_QSharedPointer::creatingVariadic()
|
||||
{
|
||||
#if !defined(Q_COMPILER_RVALUE_REFS) || !defined(Q_COMPILER_VARIADIC_TEMPLATES)
|
||||
QSKIP("This compiler is not in C++11 mode or it doesn't support rvalue refs and variadic templates");
|
||||
#else
|
||||
int i = 42;
|
||||
|
||||
{
|
||||
@ -1768,12 +1765,10 @@ void tst_QSharedPointer::creatingVariadic()
|
||||
QCOMPARE(ptr->i, 2);
|
||||
QCOMPARE(ptr->ptr, (void*)0);
|
||||
|
||||
#ifdef Q_COMPILER_NULLPTR
|
||||
NoDefaultConstructor2(nullptr, 3); // control check
|
||||
ptr = QSharedPointer<NoDefaultConstructor2>::create(nullptr, 3);
|
||||
QCOMPARE(ptr->i, 3);
|
||||
QCOMPARE(ptr->ptr, (void*)nullptr);
|
||||
#endif
|
||||
}
|
||||
{
|
||||
NoDefaultConstructorRef1 x(i); // control check
|
||||
@ -1809,7 +1804,6 @@ void tst_QSharedPointer::creatingVariadic()
|
||||
QCOMPARE(ptr->str, QString("bytearray"));
|
||||
QCOMPARE(ptr->i, 42);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QSharedPointer::creatingQObject()
|
||||
|
Loading…
Reference in New Issue
Block a user