CompareAgainstLiteralZero: fix SFINAE considerations
This issue arose during the comparison of two different ordering types. When comparing QPartialOrdering::Less to QStrongOrdering::Less, an unintended overload was considered due to the SFINAE ctor-overload of CompareAgainstLiteralZero. For example: static_assert(QPartialOrdering::Less == QStrongOrdering::Less); would consider: friend constexpr bool operator==(QtPrivate::CompareAgainstLiteralZero, QStrongOrdering rhs) noexcept as an overload. To address this, a stricter approach is now used by triggering the SFINAE-check on std::nullptr_t instead. This resolves the ambiguity while still rejecting std::nullptr_t as intended. As the compiler is unable to resolve this automatically, this refactoring is required. Pick-to: 6.5 6.2 Change-Id: I9ab7e55d2822980198f38f5a66143387999a4d94 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
parent
5f531ae2ac
commit
1d487e5593
@ -22,7 +22,7 @@ public:
|
|||||||
using SafeZero = void (CompareAgainstLiteralZero::*)();
|
using SafeZero = void (CompareAgainstLiteralZero::*)();
|
||||||
Q_IMPLICIT constexpr CompareAgainstLiteralZero(SafeZero) noexcept {}
|
Q_IMPLICIT constexpr CompareAgainstLiteralZero(SafeZero) noexcept {}
|
||||||
|
|
||||||
template <typename T, std::enable_if_t<!std::is_same_v<T, int>, bool> = false>
|
template <typename T, std::enable_if_t<std::is_null_pointer_v<T>, bool> = true>
|
||||||
CompareAgainstLiteralZero(T) = delete;
|
CompareAgainstLiteralZero(T) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user