Use ranges
C++20 brought us std::ranges for a lot of algorithms. Most of these
conversions were done using comby, similar to:
```
comby -verbose 'std::lower_bound(:[a].begin(),:[b].end(),:[c])' 'std::ranges::lower_bound(:[a], :[c])' $(git ls-files | grep "\.[hc]\(pp\)\?$") -in-place
```
Change-Id: I0c99c04e9368312555c08147d474ca93a5959e8d
Signed-off-by: Ed Tanous <edtanous@google.com>
diff --git a/include/http_utility.hpp b/include/http_utility.hpp
index eb54d0b..2fd5e14 100644
--- a/include/http_utility.hpp
+++ b/include/http_utility.hpp
@@ -8,6 +8,7 @@
#include <cctype>
#include <iomanip>
#include <ostream>
+#include <ranges>
#include <span>
#include <string>
#include <string_view>
@@ -75,10 +76,9 @@
{
return ContentType::ANY;
}
- const auto* knownContentType =
- std::find_if(contentTypes.begin(), contentTypes.end(),
- [encoding](const ContentTypePair& pair) {
- return pair.contentTypeString == encoding;
+ const auto* knownContentType = std::ranges::find_if(
+ contentTypes, [encoding](const ContentTypePair& pair) {
+ return pair.contentTypeString == encoding;
});
if (knownContentType == contentTypes.end())
@@ -88,8 +88,9 @@
}
// Not one of the types requested
- if (std::find(preferedOrder.begin(), preferedOrder.end(),
- knownContentType->contentTypeEnum) == preferedOrder.end())
+ if (std::ranges::find(preferedOrder,
+ knownContentType->contentTypeEnum) ==
+ preferedOrder.end())
{
continue;
}