From a1889b2a6703161b2206635930b9a82a63123a74 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 14 Mar 2023 16:23:31 +0100 Subject: [PATCH] Verify fix for manual get calls for QVectorD The necessary QT_ENABLE_P0846_SEMANTICS_FOR is already provided by qpoint.h) here. Add a test to confirm it works. Amends 0e22001a3bb070d4e9956e89543ec0e5ac6f23f8. [ChangeLog][QtGui][QVector2/3/4D] Fixed manual get() calls (Tuple Protocol) in C++17 mode. Task-number: QTBUG-111598 Change-Id: Id4a118b6439c2d1471b921f8d92ee558f9902eab Reviewed-by: Fabian Kosmale Reviewed-by: Qt CI Bot --- src/gui/math3d/qvectornd.h | 2 ++ .../gui/math3d/qvectornd/tst_qvectornd.cpp | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/gui/math3d/qvectornd.h b/src/gui/math3d/qvectornd.h index 639b8f0e5a..a8adf12801 100644 --- a/src/gui/math3d/qvectornd.h +++ b/src/gui/math3d/qvectornd.h @@ -15,6 +15,8 @@ QT_BEGIN_NAMESPACE +// QT_ENABLE_P0846_SEMANTICS_FOR(get) // from qpoint.h + class QVector2D; class QVector3D; class QVector4D; diff --git a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp index ade6eba796..beba252293 100644 --- a/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp +++ b/tests/auto/gui/math3d/qvectornd/tst_qvectornd.cpp @@ -1,6 +1,39 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +#include +#include +#include +#ifdef QVARIANT_H +# error "This test requires qvector{2,3,4}d.h to not include qvariant.h" +#endif + +// don't assume +template +constexpr inline bool my_is_same_v = false; +template +constexpr inline bool my_is_same_v = true; + +#define CHECK(cvref) \ + static_assert(my_is_same_v(std::declval())), float cvref >); \ + static_assert(my_is_same_v(std::declval())), float cvref >); \ + \ + static_assert(my_is_same_v(std::declval())), float cvref >); \ + static_assert(my_is_same_v(std::declval())), float cvref >); \ + static_assert(my_is_same_v(std::declval())), float cvref >); \ + \ + static_assert(my_is_same_v(std::declval())), float cvref >); \ + static_assert(my_is_same_v(std::declval())), float cvref >); \ + static_assert(my_is_same_v(std::declval())), float cvref >); \ + static_assert(my_is_same_v(std::declval())), float cvref >) + +CHECK(&); +CHECK(const &); +CHECK(&&); +CHECK(const &&); + +#undef CHECK + #include #include #include