DRY QList and QVLA operator<=>() implementation
Both QList and QVLA defined an if_has_op_less_or_op_compare_three_way trait. The only difference was that QList's implementation was using QTypeTraits::has_operator_less_than_container<>, and thus required a Container template parameter, while QVLA didn't need it. However, QVLA would still work properly with the _container version of the trait, so move the QList's implementation into QtOrderingPrivate and use it consistently in both classes. Task-number: QTBUG-120305 Change-Id: I1e4415ae5a25d4faad218bbad979a49ce851d557 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
9cbfa8cb4c
commit
3a8a8b4290
@ -1250,6 +1250,13 @@ constexpr bool compareThreeWayNoexcept() noexcept
|
||||
}
|
||||
}
|
||||
} synthThreeWay;
|
||||
|
||||
template <typename Container, typename T>
|
||||
using if_has_op_less_or_op_compare_three_way =
|
||||
std::enable_if_t<
|
||||
std::disjunction_v<QTypeTraits::has_operator_less_than_container<Container, T>,
|
||||
QTypeTraits::has_operator_compare_three_way<T>>,
|
||||
bool>;
|
||||
#endif // __cpp_lib_three_way_comparison
|
||||
|
||||
// These checks do not use Qt::compareThreeWay(), so only work for user-defined
|
||||
|
@ -349,14 +349,8 @@ private:
|
||||
}
|
||||
|
||||
#if defined(__cpp_lib_three_way_comparison) && defined(__cpp_lib_concepts)
|
||||
template <typename Container, typename U = T>
|
||||
using if_has_op_less_or_op_compare_three_way =
|
||||
std::enable_if_t<
|
||||
std::disjunction_v<QTypeTraits::has_operator_less_than_container<Container, U>,
|
||||
QTypeTraits::has_operator_compare_three_way<U>>,
|
||||
bool>;
|
||||
|
||||
template <typename U = T, if_has_op_less_or_op_compare_three_way<QList, U> = true>
|
||||
template <typename U = T,
|
||||
QtOrderingPrivate::if_has_op_less_or_op_compare_three_way<QList, U> = true>
|
||||
friend auto operator<=>(const QList &lhs, const QList &rhs)
|
||||
{
|
||||
return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(),
|
||||
|
@ -640,15 +640,8 @@ private:
|
||||
}
|
||||
|
||||
#if defined(__cpp_lib_three_way_comparison) && defined(__cpp_lib_concepts)
|
||||
template <typename U = T>
|
||||
using if_has_op_less_or_op_compare_three_way =
|
||||
std::enable_if_t<
|
||||
std::disjunction_v<QTypeTraits::has_operator_less_than<U>,
|
||||
QTypeTraits::has_operator_compare_three_way<U>>,
|
||||
bool>;
|
||||
|
||||
template <typename U = T, qsizetype Prealloc2 = Prealloc,
|
||||
if_has_op_less_or_op_compare_three_way<U> = true>
|
||||
QtOrderingPrivate::if_has_op_less_or_op_compare_three_way<QVarLengthArray, U> = true>
|
||||
friend auto
|
||||
operator<=>(const QVarLengthArray &lhs, const QVarLengthArray<T, Prealloc2> &rhs)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user