to_lower/upper_ascii for std::vector<std::string>

This commit is contained in:
Moritz Bunkus 2020-07-18 15:08:00 +02:00
parent 2a7e8784af
commit 72b060b1c9
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
2 changed files with 26 additions and 0 deletions

View File

@ -327,4 +327,27 @@ to_lower_ascii(std::string const &src) {
return to_upper_or_lower_ascii(src, true);
}
std::vector<std::string>
to_lower_upper_ascii(std::vector<std::string> const &elements,
std::function<std::string(std::string const &)> converter) {
std::vector<std::string> result;
result.reserve(elements.size());
for (auto const &element : elements)
result.emplace_back(converter(element));
return result;
}
std::vector<std::string>
to_lower_ascii(std::vector<std::string> const &src) {
return to_lower_upper_ascii(src, [](auto const &elt) { return to_lower_ascii(elt); });
}
std::vector<std::string>
to_upper_ascii(std::vector<std::string> const &src) {
return to_lower_upper_ascii(src, [](auto const &elt) { return to_upper_ascii(elt); });
}
} // mtx::string

View File

@ -102,6 +102,9 @@ join(IteratorT first,
std::string to_lower_ascii(std::string const &src);
std::string to_upper_ascii(std::string const &src);
std::vector<std::string> to_lower_ascii(std::vector<std::string> const &src);
std::vector<std::string> to_upper_ascii(std::vector<std::string> const &src);
} // mtx::string
template<typename T>