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>
This commit is contained in:
Lars Knoll 2020-10-15 08:38:48 +02:00
parent 4097653215
commit b002c48cc7

View File

@ -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());