QPartialOrdering: add missing conversion from std::{weak,strong}_ordering
QPartialOrdering is suppsed to be a drop-in replacement for std::partial_ordering, so it has to be convertible from all std::_ordering types. It was, however, only convertible from std::partial_ordering, and two user-defined conversions in a row are not allowed. Add the missing constructors. They, in turn, can then delegate to the partial_ordering constructor. Change-Id: I085d95677b258b4a61aabfd5468c1c43c2212766 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
parent
39c7bf4631
commit
a0ae96e3e7
@ -706,6 +706,12 @@ public:
|
||||
m_order = static_cast<QtPrivate::CompareUnderlyingType>(QtPrivate::LegacyUncomparable::Unordered);
|
||||
}
|
||||
|
||||
constexpr Q_IMPLICIT QPartialOrdering(std::weak_ordering stdorder) noexcept
|
||||
: QPartialOrdering(std::partial_ordering(stdorder)) {}
|
||||
|
||||
constexpr Q_IMPLICIT QPartialOrdering(std::strong_ordering stdorder) noexcept
|
||||
: QPartialOrdering(std::partial_ordering(stdorder)) {}
|
||||
|
||||
constexpr Q_IMPLICIT operator std::partial_ordering() const noexcept
|
||||
{
|
||||
if (static_cast<QtPrivate::Ordering>(m_order) == QtPrivate::Ordering::Less)
|
||||
|
@ -144,6 +144,8 @@ void tst_QCompare::legacyConversions()
|
||||
static_assert(QPartialOrdering::Unordered == NS ::partial_ordering::unordered); \
|
||||
\
|
||||
CHECK_CONVERTS(NS ::partial_ordering, QPartialOrdering); \
|
||||
CHECK_CONVERTS(NS ::weak_ordering, QPartialOrdering); \
|
||||
CHECK_CONVERTS(NS ::strong_ordering, QPartialOrdering); \
|
||||
} while (false)
|
||||
|
||||
#ifdef __cpp_lib_three_way_comparison
|
||||
|
Loading…
x
Reference in New Issue
Block a user