0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-28 08:24:08 +01:00

ircd: Add startswith_any() complement to endswith_any().

This commit is contained in:
Jason Volk 2017-09-30 19:59:14 -07:00
parent 4a6b3f5fcc
commit dd0de82e16

View file

@ -206,6 +206,7 @@ namespace ircd
template<class It> bool endswith_any(const string_view &str, const It &begin, const It &end);
bool startswith(const string_view &str, const string_view &val);
bool startswith(const string_view &str, const char &val);
template<class It> bool startswith_any(const string_view &str, const It &begin, const It &end);
bool surrounds(const string_view &str, const string_view &val);
bool surrounds(const string_view &str, const char &val);
string_view unquote(string_view str);
@ -250,6 +251,18 @@ ircd::surrounds(const string_view &str,
return startswith(str, val) && endswith(str, val);
}
template<class It>
bool
ircd::startswith_any(const string_view &str,
const It &begin,
const It &end)
{
return std::any_of(begin, end, [&str](const auto &val)
{
return startswith(str, val);
});
}
inline bool
ircd::startswith(const string_view &str,
const char &val)