diff options
Diffstat (limited to 'src/qml/qml/qqmlprivate.h')
-rw-r--r-- | src/qml/qml/qqmlprivate.h | 79 |
1 files changed, 59 insertions, 20 deletions
diff --git a/src/qml/qml/qqmlprivate.h b/src/qml/qml/qqmlprivate.h index a772d95d0c..db0535c292 100644 --- a/src/qml/qml/qqmlprivate.h +++ b/src/qml/qml/qqmlprivate.h @@ -1,12 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtQml module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:COMM$ -** +** $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 @@ -15,25 +14,26 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** $QT_END_LICENSE$ -** -** -** -** -** -** -** -** -** -** -** -** -** -** -** -** +** 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$ ** ****************************************************************************/ @@ -187,6 +187,23 @@ namespace QQmlPrivate = QQmlPrivate::createSingletonInstance<T>; }; + // from https://en.cppreference.com/w/cpp/language/static: + // If a const non-inline (since C++17) static data member or a constexpr + // static data member (since C++11)(until C++17) is odr-used, a definition + // at namespace scope is still required, but it cannot have an initializer. + // + // If a static data member is declared constexpr, it is implicitly inline + // and does not need to be redeclared at namespace scope. This redeclaration + // without an initializer (formerly required as shown above) is still + // permitted, but is deprecated. + // + // TL;DR: redundant definitions for static constexpr are required in c++11 + // but deprecated in c++17. + template<typename T> + constexpr CreateIntoFunction Constructors<T, true>::createInto; + template<typename T> + constexpr CreateSingletonFunction Constructors<T, true>::createSingletonInstance; + template<typename T> struct Constructors<T, false> { @@ -194,6 +211,12 @@ namespace QQmlPrivate static constexpr CreateSingletonFunction createSingletonInstance = nullptr; }; + // see comment above over the Constructors<T, true> definitions. + template<typename T> + constexpr CreateIntoFunction Constructors<T, false>::createInto; + template<typename T> + constexpr CreateSingletonFunction Constructors<T, false>::createSingletonInstance; + template<typename T, bool IsVoid = std::is_void<T>::value> struct ExtendedType; @@ -205,6 +228,12 @@ namespace QQmlPrivate static constexpr const QMetaObject *staticMetaObject = nullptr; }; + // see comment above over the Constructors<T, true> definitions. + template<typename T> + constexpr const CreateParentFunction ExtendedType<T, true>::createParent; + template<typename T> + constexpr const QMetaObject* ExtendedType<T, true>::staticMetaObject; + // If it's not void, we actually want an error if the ctor or the metaobject is missing. template<typename T> struct ExtendedType<T, false> @@ -213,6 +242,12 @@ namespace QQmlPrivate static constexpr const QMetaObject *staticMetaObject = &T::staticMetaObject; }; + // see comment above over the Constructors<T, true> definitions. + template<typename T> + constexpr const CreateParentFunction ExtendedType<T, false>::createParent; + template<typename T> + constexpr const QMetaObject* ExtendedType<T, false>::staticMetaObject; + template<class From, class To, int N> struct StaticCastSelectorClass { @@ -577,6 +612,10 @@ namespace QQmlPrivate static constexpr bool Value = false; }; + // see comment above over the Constructors<T, true> definitions. + template<typename T, class C> + constexpr bool QmlSingleton<T, C>::Value; + template<class T> struct QmlSingleton<T, QmlVoidT<typename T::QmlIsSingleton>> { |