From 687415e10cd7de8018410407ad0e25cf691c0d7f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 31 Jul 2023 10:03:36 -0700 Subject: [PATCH] QMetaType: fix recursive detection of std::optional operators Commit ca54b741d6edda24773137aacee229db31dd3585 used the internal has_operator_equal (and commit 01d94760d8d34e51e1442682fc151747943c7e25 copied that for has_operator_less_than) instead of using the recursive expander that was being used here. That assumed that the contained type in std::optional would always be the last final check, which is an incorrect assumption. Fixes: QTBUG-115646 Change-Id: Ifbf974a4d10745b099b1fffd177702934bec27ff Reviewed-by: Fabian Kosmale (cherry picked from commit cff13c2417225fcb5e2cca4c9a045bfe49c1034c) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/global/qtypeinfo.h | 4 ++-- .../kernel/qmetatype/tst_qmetatype.cpp | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index e6d63241bbe..f89bf72635e 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -237,7 +237,7 @@ using expand_operator_equal_recursive = std::conjunction struct expand_operator_equal_tuple : has_operator_equal {}; template -struct expand_operator_equal_tuple> : has_operator_equal {}; +struct expand_operator_equal_tuple> : expand_operator_equal_recursive {}; template struct expand_operator_equal_tuple> : expand_operator_equal_recursive {}; template @@ -277,7 +277,7 @@ using expand_operator_less_than_recursive = std::conjunction struct expand_operator_less_than_tuple : has_operator_less_than {}; template -struct expand_operator_less_than_tuple> : has_operator_less_than {}; +struct expand_operator_less_than_tuple> : expand_operator_less_than_recursive {}; template struct expand_operator_less_than_tuple> : expand_operator_less_than_recursive {}; template diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 61ea16c4da0..606a32dd4df 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -123,6 +123,26 @@ static_assert(!QTypeTraits::has_operator_less_than_v>); static_assert(QTypeTraits::has_operator_equal_v>); static_assert(!QTypeTraits::has_operator_less_than_v>); +// optionals of nesteds +static_assert(QTypeTraits::has_operator_equal_v>>); +static_assert(QTypeTraits::has_operator_less_than_v>>); +static_assert(!QTypeTraits::has_operator_equal_v>>); +static_assert(!QTypeTraits::has_operator_less_than_v>>); + +static_assert(QTypeTraits::has_operator_equal_v>); +static_assert(!QTypeTraits::has_operator_less_than_v>); +static_assert(QTypeTraits::has_operator_equal_v>>); +static_assert(!QTypeTraits::has_operator_less_than_v>>); +static_assert(QTypeTraits::has_operator_equal_v>>); +static_assert(!QTypeTraits::has_operator_less_than_v>>); + +static_assert(QTypeTraits::has_operator_equal_v>); +static_assert(!QTypeTraits::has_operator_less_than_v>); +static_assert(QTypeTraits::has_operator_equal_v>>); +static_assert(!QTypeTraits::has_operator_less_than_v>>); +static_assert(QTypeTraits::has_operator_equal_v>>); +static_assert(!QTypeTraits::has_operator_less_than_v>>); + } struct BaseGenericType