Modernize std::unique with ranges

The new return value is `std::ranges::subrange`.
This commit is contained in:
mitaclaw 2024-09-28 20:19:03 -07:00
parent be0b13da97
commit 5f3a8ff0de
2 changed files with 4 additions and 2 deletions

View File

@ -98,7 +98,8 @@ std::vector<std::string> DoFileSearch(const std::vector<std::string>& directorie
// not because std::filesystem returns duplicates). Also note that this pathname-based uniqueness
// isn't as thorough as std::filesystem::equivalent.
std::ranges::sort(result);
result.erase(std::unique(result.begin(), result.end()), result.end());
const auto unique_result = std::ranges::unique(result);
result.erase(unique_result.begin(), unique_result.end());
// Dolphin expects to be able to use "/" (DIR_SEP) everywhere.
// std::filesystem uses the OS separator.

View File

@ -129,7 +129,8 @@ BuildExpression(const std::vector<ciface::Core::DeviceContainer::InputDetection>
// Remove duplicates
std::ranges::sort(alternations);
alternations.erase(std::unique(alternations.begin(), alternations.end()), alternations.end());
const auto unique_result = std::ranges::unique(alternations);
alternations.erase(unique_result.begin(), unique_result.end());
return fmt::to_string(fmt::join(alternations, "|"));
}