From 247ab241c783f776489d8bc348a84cb533079241 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 28 Jul 2019 14:43:24 +0300 Subject: 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 Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qset/qset.pro | 2 ++ tests/auto/corelib/tools/qset/tst_qset.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'tests/auto/corelib/tools/qset') diff --git a/tests/auto/corelib/tools/qset/qset.pro b/tests/auto/corelib/tools/qset/qset.pro index d0c6337147..3ae4bc4805 100644 --- a/tests/auto/corelib/tools/qset/qset.pro +++ b/tests/auto/corelib/tools/qset/qset.pro @@ -1,6 +1,8 @@ CONFIG += testcase TARGET = tst_qset QT = core testlib +qtConfig(c++14): CONFIG += c++14 +qtConfig(c++1z): CONFIG += c++1z SOURCES = tst_qset.cpp DEFINES -= QT_NO_JAVA_STYLE_ITERATORS diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp index 31b4c0449e..8a545712a2 100644 --- a/tests/auto/corelib/tools/qset/tst_qset.cpp +++ b/tests/auto/corelib/tools/qset/tst_qset.cpp @@ -54,6 +54,7 @@ private slots: void detach(); void isDetached(); void clear(); + void cpp17ctad(); void remove(); void contains(); void containsSet(); @@ -325,6 +326,33 @@ void tst_QSet::clear() QVERIFY(set2.size() == 0); } +void tst_QSet::cpp17ctad() +{ +#ifdef __cpp_deduction_guides +#define QVERIFY_IS_SET_OF(obj, Type) \ + QVERIFY2((std::is_same>::value), \ + QMetaType::typeName(qMetaTypeId())) +#define CHECK(Type, One, Two, Three) \ + do { \ + const Type v[] = {One, Two, Three}; \ + QSet v1 = {One, Two, Three}; \ + QVERIFY_IS_SET_OF(v1, Type); \ + QSet v2(v1.begin(), v1.end()); \ + QVERIFY_IS_SET_OF(v2, Type); \ + QSet v3(std::begin(v), std::end(v)); \ + QVERIFY_IS_SET_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_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() { QSet set1; -- cgit v1.2.3