mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
Fixed buggy CSequence::sortBy when sorting by multiple members.
Implementation of Predicates::MemberLess was wrong, so replaced it with a simpler one. Also added a regression test and removed unused code.
This commit is contained in:
committed by
Klaus Basan
parent
f2bd767c63
commit
8a058202ed
@@ -62,15 +62,7 @@ namespace BlackMisc
|
||||
{
|
||||
return [vs...](const auto &a, const auto &b)
|
||||
{
|
||||
bool less = true;
|
||||
bool greater = false;
|
||||
tupleForEach(std::make_tuple(vs...), [ & ](auto member)
|
||||
{
|
||||
less = less && ! greater && (a.*member)() < (b.*member)();
|
||||
greater = (b.*member)() < (a.*member)();
|
||||
});
|
||||
Q_UNUSED(greater); // CPP style check
|
||||
return less;
|
||||
return std::forward_as_tuple((a.*vs)()...) < std::forward_as_tuple((b.*vs)()...);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -119,9 +111,7 @@ namespace BlackMisc
|
||||
{
|
||||
return [vs...](const auto &a, const auto &b)
|
||||
{
|
||||
bool equal = true;
|
||||
tupleForEach(std::make_tuple(vs...), [ & ](auto member) { equal = equal && (a.*member)() == (b.*member)(); });
|
||||
return equal;
|
||||
return std::forward_as_tuple((a.*vs)()...) == std::forward_as_tuple((b.*vs)()...);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user