Modernize std::sort with ranges and projections

In PPCTables.cpp, the code is currently unused so I was unable to test it.

In CustomPipeline.cpp, a pointer to member function cannot be used due to 16.4.5.2.1 of the C++ Standard regarding "addressable functions". https://eel.is/c++draft/namespace.std#6

In Fs.cpp and DirectoryBlob.cpp, these examples used projections in a previous iteration of this commit, but no longer do. Still, they remain in this commit because the PR they would actually belong to is already merged.
This commit is contained in:
mitaclaw
2024-09-29 11:19:33 -07:00
parent 9f972db4b8
commit 8b9f92a0af
9 changed files with 26 additions and 38 deletions

View File

@ -485,10 +485,7 @@ static bool Pack(const std::function<bool()>& cancelled, const File::FSTEntry& e
static void SortFST(File::FSTEntry* root)
{
std::sort(root->children.begin(), root->children.end(),
[](const File::FSTEntry& lhs, const File::FSTEntry& rhs) {
return lhs.virtualName < rhs.virtualName;
});
std::ranges::sort(root->children, {}, &File::FSTEntry::virtualName);
for (auto& child : root->children)
SortFST(&child);
}