QMetaType of non-const ref: play nice with template instantiations

...by making QMetaTypeId2 contain all expected members.
While we don't allow QMetaType from non-const references, we want to
get to the static_assert telling us as much, instead of running into
more or less incomprehensible error messages in the depths of
qmetatype.h.

Task-number: QTBUG-106672
Change-Id: Ica9b13fee95eda97cafab2cccdc5249dfc3dcdf2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 9b3de58d2dfedfdd8097b329438a2f2f086aa43f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Fabian Kosmale 2022-09-18 16:27:32 +02:00 committed by Qt Cherry-pick Bot
parent b404ad5894
commit 617e1fe20a

View File

@ -1127,7 +1127,12 @@ template <typename T>
struct QMetaTypeId2<const T&> : QMetaTypeId2<T> {};
template <typename T>
struct QMetaTypeId2<T&> { enum {Defined = false }; };
struct QMetaTypeId2<T&>
{
using NameAsArrayType = void;
enum { Defined = false, IsBuiltIn = false };
static inline constexpr int qt_metatype_id() { return 0; }
};
namespace QtPrivate {
template <typename T, bool Defined = QMetaTypeId2<T>::Defined>