src: Make strifind functin template

This commit is contained in:
Tatsuhiro Tsujikawa 2016-03-25 22:56:23 +09:00
parent 72d8d78d36
commit 2182a85875
2 changed files with 4 additions and 6 deletions

View File

@ -348,11 +348,6 @@ time_t parse_http_date(const StringRef &s) {
return nghttp2_timegm_without_yday(&tm);
}
bool strifind(const StringRef &a, const StringRef &b) {
return std::search(std::begin(a), std::end(a), std::begin(b), std::end(b),
CaseCmp()) != std::end(a);
}
char upcase(char c) {
if ('a' <= c && c <= 'z') {
return c - 'a' + 'A';

View File

@ -325,7 +325,10 @@ bool streq_l(const CharT(&a)[N], const T &b) {
// Returns true if |a| contains |b|. If both |a| and |b| are empty,
// this function returns false.
bool strifind(const StringRef &a, const StringRef &b);
template <typename S, typename T> bool strifind(const S &a, const T &b) {
return std::search(a.begin(), a.end(), b.begin(), b.end(), CaseCmp()) !=
a.end();
}
template <typename InputIt> void inp_strlower(InputIt first, InputIt last) {
std::transform(first, last, first, lowcase);