0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 08:42:34 +01:00

ircd::util: Use std::all_of for boolean ctype test.

This commit is contained in:
Jason Volk 2018-02-15 12:09:17 -08:00
parent bfcfacfc50
commit 3d216fda84

View file

@ -227,13 +227,21 @@ ctype(const string_view &s)
return ctype<test>(begin(s), end(s));
}
/// convenience wrapper for ctype(string_view) to avoid the -1 test for
/// success in any intuitive boolean statement.
/// Boolean alternative for ctype to avoid the -1/pos test
template<int (&test)(int) = std::isprint>
ssize_t
all_of(const char *begin,
const char *const &end)
{
return std::all_of(begin, end, test);
}
/// Boolean alternative for ctype(string_view)
template<int (&test)(int)>
bool
valid(const string_view &s)
all_of(const string_view &s)
{
return ctype<test>(s) == -1L;
return std::all_of(begin(s), end(s), test);
}
/// Zero testing functor (work in progress)