diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-07-28 14:43:24 +0300 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-08-07 23:09:03 +0300 |
commit | 247ab241c783f776489d8bc348a84cb533079241 (patch) | |
tree | d64ee3dc0ba59d86a6f723e7dea533c7e3b55df9 /tests/auto/corelib/tools/qlist | |
parent | bf99c4bf553ea750f68745133960084f0b4c0490 (diff) |
QVector/QList/QLinkedList/QVarLengthArray/QSet: add missing deduction guides
Amends 2e1763d83a1dacfc5b747934fb77fa7cec7bfe47.
The new range ctors need deduction guides, since the compiler can't
deduce the value_type from a pair of iterators.
Change-Id: I3ec1e5f91305b317c443b6a70246be416b55bad9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/tools/qlist')
-rw-r--r-- | tests/auto/corelib/tools/qlist/qlist.pro | 2 | ||||
-rw-r--r-- | tests/auto/corelib/tools/qlist/tst_qlist.cpp | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qlist/qlist.pro b/tests/auto/corelib/tools/qlist/qlist.pro index 47f0140abb..118c607880 100644 --- a/tests/auto/corelib/tools/qlist/qlist.pro +++ b/tests/auto/corelib/tools/qlist/qlist.pro @@ -1,4 +1,6 @@ CONFIG += testcase TARGET = tst_qlist QT = core testlib +qtConfig(c++14): CONFIG += c++14 +qtConfig(c++1z): CONFIG += c++1z SOURCES = $$PWD/tst_qlist.cpp diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index 5a485e88d2..cc9a3a16d1 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -310,6 +310,7 @@ private slots: void lastComplex() const; void constFirst() const; void constLast() const; + void cpp17ctad() const; void beginOptimal() const; void beginMovable() const; void beginComplex() const; @@ -864,6 +865,33 @@ void tst_QList::constLast() const QVERIFY(listCopy.isSharedWith(list)); } +void tst_QList::cpp17ctad() const +{ +#ifdef __cpp_deduction_guides +#define QVERIFY_IS_LIST_OF(obj, Type) \ + QVERIFY2((std::is_same<decltype(obj), QList<Type>>::value), \ + QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>())) +#define CHECK(Type, One, Two, Three) \ + do { \ + const Type v[] = {One, Two, Three}; \ + QList v1 = {One, Two, Three}; \ + QVERIFY_IS_LIST_OF(v1, Type); \ + QList v2(v1.begin(), v1.end()); \ + QVERIFY_IS_LIST_OF(v2, Type); \ + QList v3(std::begin(v), std::end(v)); \ + QVERIFY_IS_LIST_OF(v3, Type); \ + } while (false) \ + /*end*/ + CHECK(int, 1, 2, 3); + CHECK(double, 1.0, 2.0, 3.0); + CHECK(QString, QStringLiteral("one"), QStringLiteral("two"), QStringLiteral("three")); +#undef QVERIFY_IS_LIST_OF +#undef CHECK +#else + QSKIP("This test requires C++17 Constructor Template Argument Deduction support enabled in the compiler."); +#endif +} + template<typename T> void tst_QList::last() const { |