summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-10-15 08:38:48 +0200
committerLars Knoll <lars.knoll@qt.io>2020-10-16 09:48:09 +0200
commitb002c48cc799ebe613ed5fadebd0f5956e214388 (patch)
tree2abac27e65151e72a7191080b1a562220e9c240d /src/corelib
parent40976532158fc49be45bb976455f48e98f9690cf (diff)
Disallow promotion of bool and char in qMin and friends
Feedback on the API review. Make sure, qMin<true, 'a'> and similar constructs don't compile. Change-Id: I59a66348a4168fe306159ddaf2595838d4ed66d1 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qglobal.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 6999538ee8..d9ba41e70a 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -642,7 +642,9 @@ namespace detail {
template<typename T, typename U,
typename = std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U> &&
std::is_floating_point_v<T> == std::is_floating_point_v<U> &&
- std::is_signed_v<T> == std::is_signed_v<U>> >
+ std::is_signed_v<T> == std::is_signed_v<U> &&
+ !std::is_same_v<T, bool> && !std::is_same_v<U, bool> &&
+ !std::is_same_v<T, char> && !std::is_same_v<U, char>>>
struct Promoted
{
using type = decltype(T() + U());