diff options
author | Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> | 2021-09-30 14:12:02 +0200 |
---|---|---|
committer | Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> | 2021-10-02 17:54:39 +0200 |
commit | 9a3f4afb700bb4fb6c4d26120de71fb61ffab032 (patch) | |
tree | 5d9942baad0301712beb1f462eee6c7c6ca8432f | |
parent | a1e7c441de16cb4e8d6bdac39160759116ecd233 (diff) |
Remove checks for features available in C++17
This patch removes most of the checks that are made using C++20
__cpp_* macros for features available in C++17 and earlier.
Library feature check macros (__cpp_lib_*) are unaffected.
Change-Id: I557b2bd0d4ff09b13837555e9880eb28e0355f64
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/concurrent/qtconcurrentfunctionwrappers.h | 2 | ||||
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 12 | ||||
-rw-r--r-- | src/corelib/kernel/qobjectdefs_impl.h | 4 | ||||
-rw-r--r-- | src/corelib/thread/qlocking_p.h | 4 | ||||
-rw-r--r-- | src/corelib/tools/qlist.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qscopeguard.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qset.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qrgba64.h | 4 | ||||
-rw-r--r-- | tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 3 | ||||
-rw-r--r-- | tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp | 4 | ||||
-rw-r--r-- | tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/text/qstringview/tst_qstringview.cpp | 12 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qlist/tst_qlist.cpp | 4 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp | 12 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qset/tst_qset.cpp | 4 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp | 5 |
17 files changed, 2 insertions, 78 deletions
diff --git a/src/concurrent/qtconcurrentfunctionwrappers.h b/src/concurrent/qtconcurrentfunctionwrappers.h index 1c882d3f19..08966115d6 100644 --- a/src/concurrent/qtconcurrentfunctionwrappers.h +++ b/src/concurrent/qtconcurrentfunctionwrappers.h @@ -129,7 +129,6 @@ struct ReduceResultType<R(*)(A...)> using ResultType = typename std::tuple_element<0, std::tuple<A...>>::type; }; -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 template <class U, class V> struct ReduceResultType<void(*)(U&,V) noexcept> { @@ -141,7 +140,6 @@ struct ReduceResultType<T(C::*)(U) noexcept> { using ResultType = C; }; -#endif template<class T, class Enable = void> struct hasCallOperator : std::false_type diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 273575c31f..bfa4f89105 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1114,10 +1114,8 @@ # define Q_DECL_DEPRECATED_X(x) [[deprecated(x)]] #endif -#if defined(__cpp_enumerator_attributes) && __cpp_enumerator_attributes >= 201411 -# define Q_DECL_ENUMERATOR_DEPRECATED Q_DECL_DEPRECATED -# define Q_DECL_ENUMERATOR_DEPRECATED_X(x) Q_DECL_DEPRECATED_X(x) -#endif +#define Q_DECL_ENUMERATOR_DEPRECATED Q_DECL_DEPRECATED +#define Q_DECL_ENUMERATOR_DEPRECATED_X(x) Q_DECL_DEPRECATED_X(x) /* * Fallback macros to certain compiler features @@ -1153,12 +1151,6 @@ #ifndef Q_DECL_DEPRECATED_X # define Q_DECL_DEPRECATED_X(text) Q_DECL_DEPRECATED #endif -#ifndef Q_DECL_ENUMERATOR_DEPRECATED -# define Q_DECL_ENUMERATOR_DEPRECATED -#endif -#ifndef Q_DECL_ENUMERATOR_DEPRECATED_X -# define Q_DECL_ENUMERATOR_DEPRECATED_X(x) -#endif #ifndef Q_DECL_EXPORT # define Q_DECL_EXPORT #endif diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index c35d9aa7a7..a3068e1712 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -158,7 +158,6 @@ namespace QtPrivate { (o->*f)((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[II+1]))...), ApplyReturnValue<R>(arg[0]); } }; -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 template <int... II, typename... SignalArgs, typename R, typename... SlotArgs, typename SlotRet, class Obj> struct FunctorCall<IndexesList<II...>, List<SignalArgs...>, R, SlotRet (Obj::*)(SlotArgs...) noexcept> { static void call(SlotRet (Obj::*f)(SlotArgs...) noexcept, Obj *o, void **arg) { @@ -171,7 +170,6 @@ namespace QtPrivate { (o->*f)((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[II+1]))...), ApplyReturnValue<R>(arg[0]); } }; -#endif template<class Obj, typename Ret, typename... Args> struct FunctionPointer<Ret (Obj::*) (Args...)> { @@ -210,7 +208,6 @@ namespace QtPrivate { } }; -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 template<class Obj, typename Ret, typename... Args> struct FunctionPointer<Ret (Obj::*) (Args...) noexcept> { typedef Obj Object; @@ -247,7 +244,6 @@ namespace QtPrivate { FunctorCall<typename Indexes<ArgumentCount>::Value, SignalArgs, R, Function>::call(f, arg); } }; -#endif template<typename Function, int N> struct Functor { diff --git a/src/corelib/thread/qlocking_p.h b/src/corelib/thread/qlocking_p.h index 9a796cf7f7..5fb80454df 100644 --- a/src/corelib/thread/qlocking_p.h +++ b/src/corelib/thread/qlocking_p.h @@ -84,15 +84,11 @@ QT_BEGIN_NAMESPACE namespace { template <typename Mutex, typename Lock = -#if defined(__cpp_guaranteed_copy_elision) && __cpp_guaranteed_copy_elision >= 201606L # if defined(__cpp_lib_scoped_lock) && __cpp_lib_scoped_lock >= 201703L std::scoped_lock # else std::lock_guard # endif -#else - std::unique_lock -#endif <typename std::decay<Mutex>::type> > Lock qt_scoped_lock(Mutex &mutex) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 0329dd37da..07e5970faf 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -663,12 +663,10 @@ public: } }; -#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201606 template <typename InputIterator, typename ValueType = typename std::iterator_traits<InputIterator>::value_type, QtPrivate::IfIsInputIterator<InputIterator> = true> QList(InputIterator, InputIterator) -> QList<ValueType>; -#endif template <typename T> inline void QList<T>::resize_internal(qsizetype newSize) diff --git a/src/corelib/tools/qscopeguard.h b/src/corelib/tools/qscopeguard.h index 8270f41a2e..cc9e8db209 100644 --- a/src/corelib/tools/qscopeguard.h +++ b/src/corelib/tools/qscopeguard.h @@ -86,9 +86,7 @@ private: bool m_invoke = true; }; -#ifdef __cpp_deduction_guides template <typename F> QScopeGuard(F(&)()) -> QScopeGuard<F(*)()>; -#endif //! [qScopeGuard] template <typename F> diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 565b8b5691..9aecbff5bc 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -235,12 +235,10 @@ private: Hash q_hash; }; -#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201606 template <typename InputIterator, typename ValueType = typename std::iterator_traits<InputIterator>::value_type, QtPrivate::IfIsInputIterator<InputIterator> = true> QSet(InputIterator, InputIterator) -> QSet<ValueType>; -#endif template <typename T> size_t qHash(const QSet<T> &key, size_t seed = 0) diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 3aa5e70114..90be3b3299 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -386,12 +386,10 @@ private: } }; -#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201606 template <typename InputIterator, typename ValueType = typename std::iterator_traits<InputIterator>::value_type, QtPrivate::IfIsInputIterator<InputIterator> = true> QVarLengthArray(InputIterator, InputIterator) -> QVarLengthArray<ValueType>; -#endif template <class T, qsizetype Prealloc> Q_INLINE_TEMPLATE QVarLengthArray<T, Prealloc>::QVarLengthArray(qsizetype asize) diff --git a/src/gui/painting/qrgba64.h b/src/gui/painting/qrgba64.h index 2c644c4cf0..e326c03bfc 100644 --- a/src/gui/painting/qrgba64.h +++ b/src/gui/painting/qrgba64.h @@ -118,7 +118,6 @@ public: constexpr quint8 alpha8() const { return div_257(alpha()); } constexpr uint toArgb32() const { -#if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304 quint64 br = rgba & Q_UINT64_C(0xffff0000ffff); quint64 ag = (rgba >> 16) & Q_UINT64_C(0xffff0000ffff); br += Q_UINT64_C(0x8000000080); @@ -136,9 +135,6 @@ public: | (ag & 0xff00) | ((br >> 32) & 0xff); #endif -#else - return uint((alpha8() << 24) | (red8() << 16) | (green8() << 8) | blue8()); -#endif } constexpr ushort toRgb16() const { diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index a5bf9cf34f..7323cfe545 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -535,8 +535,6 @@ void tst_QGlobal::testqOverload() QVERIFY(QConstOverload<QByteArray>::of(&Overloaded::mixedFoo) == static_cast<void (Overloaded::*)(QByteArray) const>(&Overloaded::mixedFoo)); -#if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304 // C++14 - // void returning free overloaded functions QVERIFY(qOverload<>(&freeOverloaded) == static_cast<void (*)()>(&freeOverloaded)); @@ -580,7 +578,6 @@ void tst_QGlobal::testqOverload() QVERIFY(qConstOverload<QByteArray>(&Overloaded::mixedFoo) == static_cast<void (Overloaded::*)(QByteArray) const>(&Overloaded::mixedFoo)); -#endif #endif } diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp index 968ccee043..f13ffe8354 100644 --- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp @@ -827,7 +827,6 @@ void tst_QMetaObject::invokePointer() QCOMPARE(obj.slotResult, QString("sl1:bubu")); } QCOMPARE(countedStructObjectsCount, 0); -#ifdef __cpp_init_captures { CountedStruct str; std::unique_ptr<int> ptr( new int ); @@ -835,7 +834,6 @@ void tst_QMetaObject::invokePointer() QCOMPARE(obj.slotResult, QString("sl1:1")); } QCOMPARE(countedStructObjectsCount, 0); -#endif } void tst_QMetaObject::invokeQueuedMetaMember() @@ -1151,7 +1149,6 @@ void tst_QMetaObject::invokeBlockingQueuedPointer() QCOMPARE(exp, QString("yessir")); QCOMPARE(obj.slotResult, QString("sl1:bubu")); } -#ifdef __cpp_init_captures { std::unique_ptr<int> ptr(new int); QVERIFY(QMetaObject::invokeMethod(&obj, @@ -1159,7 +1156,6 @@ void tst_QMetaObject::invokeBlockingQueuedPointer() Qt::BlockingQueuedConnection)); QCOMPARE(obj.slotResult, QString("sl1:hehe")); } -#endif QVERIFY(QMetaObject::invokeMethod(&obj, [&](){obj.moveToThread(QThread::currentThread());}, Qt::BlockingQueuedConnection)); t.quit(); QVERIFY(t.wait()); diff --git a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp index b42019bf04..543449c5e6 100644 --- a/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp +++ b/tests/auto/corelib/text/qstringapisymmetry/tst_qstringapisymmetry.cpp @@ -1509,7 +1509,6 @@ void tst_QStringApiSymmetry::tok_impl() const QCOMPARE(toQStringList(tok), resultCS); } -#ifdef __cpp_deduction_guides QCOMPARE(toQStringList(QStringTokenizer{haystack, needle}), resultCS); QCOMPARE(toQStringList(QStringTokenizer{haystack, needle, Qt::KeepEmptyParts, Qt::CaseSensitive}), resultCS); QCOMPARE(toQStringList(QStringTokenizer{haystack, needle, Qt::CaseInsensitive, Qt::KeepEmptyParts}), resultCIS); @@ -1522,7 +1521,6 @@ void tst_QStringApiSymmetry::tok_impl() const // yet `tok` should have kept a copy alive as needed: QCOMPARE(toQStringList(tok), resultCS); } -#endif // __cpp_deduction_guides if constexpr (has_tokenize_method_v<Haystack>) { QCOMPARE(toQStringList(haystack.tokenize(needle)), resultCS); diff --git a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp index a78004f04d..3d95022181 100644 --- a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp +++ b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp @@ -552,13 +552,11 @@ void tst_QStringView::tokenize() const QFETCH(const QStringList, result); // lvalue QString -#ifdef __cpp_deduction_guides { auto rit = result.cbegin(); for (auto sv : QStringTokenizer{str, sep}) QCOMPARE(sv, *rit++); } -#endif { auto rit = result.cbegin(); for (auto sv : QStringView{str}.tokenize(sep)) @@ -566,13 +564,11 @@ void tst_QStringView::tokenize() const } // rvalue QString -#ifdef __cpp_deduction_guides { auto rit = result.cbegin(); for (auto sv : QStringTokenizer{str, QString{sep}}) QCOMPARE(sv, *rit++); } -#endif { auto rit = result.cbegin(); for (auto sv : QStringView{str}.tokenize(QString{sep})) @@ -580,13 +576,11 @@ void tst_QStringView::tokenize() const } // (rvalue) QChar -#ifdef __cpp_deduction_guides if (sep.size() == 1) { auto rit = result.cbegin(); for (auto sv : QStringTokenizer{str, sep.front()}) QCOMPARE(sv, *rit++); } -#endif if (sep.size() == 1) { auto rit = result.cbegin(); for (auto sv : QStringView{str}.tokenize(sep.front())) @@ -594,13 +588,11 @@ void tst_QStringView::tokenize() const } // (rvalue) char16_t -#ifdef __cpp_deduction_guides if (sep.size() == 1) { auto rit = result.cbegin(); for (auto sv : QStringTokenizer{str, *qToStringViewIgnoringNull(sep).utf16()}) QCOMPARE(sv, *rit++); } -#endif if (sep.size() == 1) { auto rit = result.cbegin(); for (auto sv : QStringView{str}.tokenize(*qToStringViewIgnoringNull(sep).utf16())) @@ -615,20 +607,17 @@ void tst_QStringView::tokenize() const return literal; }; const std::unique_ptr<const char16_t[]> literal = make_literal(sep); -#ifdef __cpp_deduction_guides { auto rit = result.cbegin(); for (auto sv : QStringTokenizer{str, literal.get()}) QCOMPARE(sv, *rit++); } -#endif { auto rit = result.cbegin(); for (auto sv : QStringView{str}.tokenize(literal.get())) QCOMPARE(sv, *rit++); } -#ifdef __cpp_deduction_guides #ifdef __cpp_lib_ranges // lvalue QString { @@ -657,7 +646,6 @@ void tst_QStringView::tokenize() const QCOMPARE(result, actual); } #endif // __cpp_lib_ranges -#endif // __cpp_deduction_guides } template <typename Char> diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index 48931a81ea..3d26720fab 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -1143,7 +1143,6 @@ void tst_QList::count() const void tst_QList::cpp17ctad() const { -#ifdef __cpp_deduction_guides #define QVERIFY_IS_VECTOR_OF(obj, Type) \ QVERIFY2((std::is_same<decltype(obj), QList<Type>>::value), \ QMetaType::fromType<decltype(obj)::value_type>().name()) @@ -1163,9 +1162,6 @@ void tst_QList::cpp17ctad() const CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three")); #undef QVERIFY_IS_VECTOR_OF #undef CHECK -#else - QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler."); -#endif } void tst_QList::data() const diff --git a/tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp b/tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp index 21567137fd..90b3557ef5 100644 --- a/tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp +++ b/tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp @@ -94,7 +94,6 @@ static int s_globalState = 0; void tst_QScopeGuard::construction() { -#ifdef __cpp_deduction_guides QScopeGuard fromLambda([] { }); QScopeGuard fromFunction(func); QScopeGuard fromFunctionPointer(&func); @@ -105,14 +104,10 @@ void tst_QScopeGuard::construction() std::function<void()> stdFunction(func); QScopeGuard fromNamedStdFunction(stdFunction); #endif -#else - QSKIP("This test requires C++17 Class Template Argument Deduction support enabled in the compiler."); -#endif } void tst_QScopeGuard::constructionFromLvalue() { -#ifdef __cpp_deduction_guides Callable::resetCounts(); { Callable callable; @@ -127,14 +122,10 @@ void tst_QScopeGuard::constructionFromLvalue() } QCOMPARE(Callable::copied, 1); QCOMPARE(Callable::moved, 0); -#else - QSKIP("This test requires C++17 Class Template Argument Deduction support enabled in the compiler."); -#endif } void tst_QScopeGuard::constructionFromRvalue() { -#ifdef __cpp_deduction_guides Callable::resetCounts(); { Callable callable; @@ -149,9 +140,6 @@ void tst_QScopeGuard::constructionFromRvalue() } QCOMPARE(Callable::copied, 0); QCOMPARE(Callable::moved, 1); -#else - QSKIP("This test requires C++17 Class Template Argument Deduction support enabled in the compiler."); -#endif } void tst_QScopeGuard::leavingScope() diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp index 490e8e97fd..421657dc27 100644 --- a/tests/auto/corelib/tools/qset/tst_qset.cpp +++ b/tests/auto/corelib/tools/qset/tst_qset.cpp @@ -339,7 +339,6 @@ void tst_QSet::clear() void tst_QSet::cpp17ctad() { -#ifdef __cpp_deduction_guides #define QVERIFY_IS_SET_OF(obj, Type) \ QVERIFY2((std::is_same<decltype(obj), QSet<Type>>::value), \ QMetaType::fromType<decltype(obj)::value_type>().name()) @@ -359,9 +358,6 @@ void tst_QSet::cpp17ctad() CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three")); #undef QVERIFY_IS_SET_OF #undef CHECK -#else - QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler."); -#endif } void tst_QSet::remove() diff --git a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp index 0598a39cb6..6e95577655 100644 --- a/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp +++ b/tests/auto/corelib/tools/qvarlengtharray/tst_qvarlengtharray.cpp @@ -907,7 +907,6 @@ void tst_QVarLengthArray::count() void tst_QVarLengthArray::cpp17ctad() { -#ifdef __cpp_deduction_guides #define QVERIFY_IS_VLA_OF(obj, Type) \ QVERIFY2((std::is_same<decltype(obj), QVarLengthArray<Type>>::value), \ QMetaType::fromType<decltype(obj)::value_type>().name()) @@ -927,10 +926,6 @@ void tst_QVarLengthArray::cpp17ctad() CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three")); #undef QVERIFY_IS_VLA_OF #undef CHECK -#else - QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler."); -#endif - } void tst_QVarLengthArray::first() |