summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/kernel/qobjectdefs_impl.h4
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp6
2 files changed, 10 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h
index 31ecc8b20d..aed50d6c5a 100644
--- a/src/corelib/kernel/qobjectdefs_impl.h
+++ b/src/corelib/kernel/qobjectdefs_impl.h
@@ -285,11 +285,15 @@ namespace QtPrivate {
{
};
+ template <typename T>
+ using is_bool = std::is_same<bool, typename std::decay<T>::type>;
+
template<typename From, typename To>
struct AreArgumentsNarrowedBase<From, To, typename std::enable_if<sizeof(From) && sizeof(To)>::type>
: std::integral_constant<bool,
(std::is_floating_point<From>::value && std::is_integral<To>::value) ||
(std::is_floating_point<From>::value && std::is_floating_point<To>::value && sizeof(From) > sizeof(To)) ||
+ ((std::is_pointer<From>::value || std::is_member_pointer<From>::value) && QtPrivate::is_bool<To>::value) ||
((std::is_integral<From>::value || std::is_enum<From>::value) && std::is_floating_point<To>::value) ||
(std::is_integral<From>::value && std::is_integral<To>::value
&& (sizeof(From) > sizeof(To)
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 21615d6ec4..63d06497ce 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -7462,6 +7462,12 @@ void tst_QObject::checkArgumentsForNarrowing()
FITS(bool, const QObject *&);
FITS(int (*)(bool), void (QObject::*)());
+ {
+ // wg21.link/P1957
+ NARROWS(char*, bool);
+ NARROWS(void (QObject::*)(), bool);
+ }
+
#undef IS_UNSCOPED_ENUM_SIGNED
#undef NARROWS_IF