Verify fix for manual get<I> calls for QVector<N>D

The necessary QT_ENABLE_P0846_SEMANTICS_FOR is already provided by
qpoint.h) here. Add a test to confirm it works.

Amends 0e22001a3b.

[ChangeLog][QtGui][QVector2/3/4D] Fixed manual get<I>() calls
(Tuple Protocol) in C++17 mode.

Task-number: QTBUG-111598
Change-Id: Id4a118b6439c2d1471b921f8d92ee558f9902eab
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2023-03-14 16:23:31 +01:00
parent eb9c8042cf
commit a1889b2a67
2 changed files with 35 additions and 0 deletions

View File

@ -15,6 +15,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
// QT_ENABLE_P0846_SEMANTICS_FOR(get) // from qpoint.h
class QVector2D; class QVector2D;
class QVector3D; class QVector3D;
class QVector4D; class QVector4D;

View File

@ -1,6 +1,39 @@
// Copyright (C) 2016 The Qt Company Ltd. // Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QVector2D>
#include <QVector3D>
#include <QVector4D>
#ifdef QVARIANT_H
# error "This test requires qvector{2,3,4}d.h to not include qvariant.h"
#endif
// don't assume <type_traits>
template <typename T, typename U>
constexpr inline bool my_is_same_v = false;
template <typename T>
constexpr inline bool my_is_same_v<T, T> = true;
#define CHECK(cvref) \
static_assert(my_is_same_v<decltype(get<0>(std::declval<QVector2D cvref >())), float cvref >); \
static_assert(my_is_same_v<decltype(get<1>(std::declval<QVector2D cvref >())), float cvref >); \
\
static_assert(my_is_same_v<decltype(get<0>(std::declval<QVector3D cvref >())), float cvref >); \
static_assert(my_is_same_v<decltype(get<1>(std::declval<QVector3D cvref >())), float cvref >); \
static_assert(my_is_same_v<decltype(get<2>(std::declval<QVector3D cvref >())), float cvref >); \
\
static_assert(my_is_same_v<decltype(get<0>(std::declval<QVector4D cvref >())), float cvref >); \
static_assert(my_is_same_v<decltype(get<1>(std::declval<QVector4D cvref >())), float cvref >); \
static_assert(my_is_same_v<decltype(get<2>(std::declval<QVector4D cvref >())), float cvref >); \
static_assert(my_is_same_v<decltype(get<3>(std::declval<QVector4D cvref >())), float cvref >)
CHECK(&);
CHECK(const &);
CHECK(&&);
CHECK(const &&);
#undef CHECK
#include <QTest> #include <QTest>
#include <QtCore/qmath.h> #include <QtCore/qmath.h>
#include <QtGui/qvector2d.h> #include <QtGui/qvector2d.h>