Use std::less instead of operator < in less_first and less_second

According to the standard, if p1 and p2 are both pointers, p1 < p2 and
p2 < p1 can both be false in theory in some cases:

https://eel.is/c++draft/expr.rel#4.3

std::less<void> yields a implementation-defined strict total order over
pointers:

https://eel.is/c++draft/comparisons.general

Differential Revision: https://reviews.llvm.org/D108733
This commit is contained in:
Akira Hatanaka 2021-08-25 13:11:19 -07:00
parent dbf0d8118c
commit 8f859cc349
1 changed files with 2 additions and 2 deletions

View File

@ -1273,7 +1273,7 @@ template <typename ContainerTy> auto make_second_range(ContainerTy &&c) {
/// compares less than the first component of another std::pair.
struct less_first {
template <typename T> bool operator()(const T &lhs, const T &rhs) const {
return lhs.first < rhs.first;
return std::less<>()(lhs.first, rhs.first);
}
};
@ -1281,7 +1281,7 @@ struct less_first {
/// compares less than the second component of another std::pair.
struct less_second {
template <typename T> bool operator()(const T &lhs, const T &rhs) const {
return lhs.second < rhs.second;
return std::less<>()(lhs.second, rhs.second);
}
};