diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index e5914414f23..ec435867656 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -227,8 +227,8 @@ template struct is_container : std::false_type {}; template struct is_container().begin() != std::declval().end()), bool>, - typename T::value_type + typename T::value_type, + std::is_convertible().begin() != std::declval().end()), bool> >> : std::true_type {}; @@ -258,7 +258,11 @@ struct expand_operator_equal_container : expand_operator_equal_tuple {}; // if T::value_type exists, check first T::value_type, then T itself template struct expand_operator_equal_container : - std::conjunction, expand_operator_equal_tuple> {}; + std::conjunction< + std::disjunction< + std::is_same, // avoid endless recursion + expand_operator_equal + >, expand_operator_equal_tuple> {}; // recursively check the template arguments of a tuple like object template @@ -294,7 +298,12 @@ template struct expand_operator_less_than_container : expand_operator_less_than_tuple {}; template struct expand_operator_less_than_container : - std::conjunction, expand_operator_less_than_tuple> {}; + std::conjunction< + std::disjunction< + std::is_same, + expand_operator_less_than + >, expand_operator_less_than_tuple + > {}; template using expand_operator_less_than_recursive = std::conjunction...>; diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 1978e9e1b7c..c1aab965a88 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -2778,5 +2778,15 @@ Q_DECLARE_METATYPE(UndefinedFunction2); Q_DECLARE_METATYPE(UndefinedFunction3); Q_DECLARE_METATYPE(UndefinedFunction4); +struct S { + using value_type = S; // used to cause compilation error with Qt6 + int begin(); + int end(); +}; + +// should not cause a compilation failure +// used to cause issues due to S being equal to S::value_type +Q_DECLARE_METATYPE(S) + QTEST_MAIN(tst_QMetaType) #include "tst_qmetatype.moc"