diff options
Diffstat (limited to 'src/gui/math3d/qvectornd.h')
-rw-r--r-- | src/gui/math3d/qvectornd.h | 74 |
1 files changed, 14 insertions, 60 deletions
diff --git a/src/gui/math3d/qvectornd.h b/src/gui/math3d/qvectornd.h index dec98bd936..a8adf12801 100644 --- a/src/gui/math3d/qvectornd.h +++ b/src/gui/math3d/qvectornd.h @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QVECTORND_H #define QVECTORND_H @@ -46,8 +10,13 @@ #include <QtCore/qrect.h> #include <QtCore/qmath.h> +#include <QtCore/q20type_traits.h> +#include <QtCore/q23utility.h> + QT_BEGIN_NAMESPACE +// QT_ENABLE_P0846_SEMANTICS_FOR(get) // from qpoint.h + class QVector2D; class QVector3D; class QVector4D; @@ -181,13 +150,10 @@ private: template <std::size_t I, typename V, std::enable_if_t<(I < 2), bool> = true, - std::enable_if_t<std::is_same_v<std::decay_t<V>, QVector2D>, bool> = true> + std::enable_if_t<std::is_same_v<q20::remove_cvref_t<V>, QVector2D>, bool> = true> friend constexpr decltype(auto) get(V &&vec) noexcept { - if constexpr (I == 0) - return (std::forward<V>(vec).v[0]); - else if constexpr (I == 1) - return (std::forward<V>(vec).v[1]); + return q23::forward_like<V>(vec.v[I]); } }; @@ -343,15 +309,10 @@ private: template <std::size_t I, typename V, std::enable_if_t<(I < 3), bool> = true, - std::enable_if_t<std::is_same_v<std::decay_t<V>, QVector3D>, bool> = true> + std::enable_if_t<std::is_same_v<q20::remove_cvref_t<V>, QVector3D>, bool> = true> friend constexpr decltype(auto) get(V &&vec) noexcept { - if constexpr (I == 0) - return (std::forward<V>(vec).v[0]); - else if constexpr (I == 1) - return (std::forward<V>(vec).v[1]); - else if constexpr (I == 2) - return (std::forward<V>(vec).v[2]); + return q23::forward_like<V>(vec.v[I]); } }; @@ -500,17 +461,10 @@ private: template <std::size_t I, typename V, std::enable_if_t<(I < 4), bool> = true, - std::enable_if_t<std::is_same_v<std::decay_t<V>, QVector4D>, bool> = true> + std::enable_if_t<std::is_same_v<q20::remove_cvref_t<V>, QVector4D>, bool> = true> friend constexpr decltype(auto) get(V &&vec) noexcept { - if constexpr (I == 0) - return (std::forward<V>(vec).v[0]); - else if constexpr (I == 1) - return (std::forward<V>(vec).v[1]); - else if constexpr (I == 2) - return (std::forward<V>(vec).v[2]); - else if constexpr (I == 3) - return (std::forward<V>(vec).v[3]); + return q23::forward_like<V>(vec.v[I]); } }; |