From 3d216fda84ba5b67248aa70ca75386f54a692ed5 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 15 Feb 2018 12:09:17 -0800 Subject: [PATCH] ircd::util: Use std::all_of for boolean ctype test. --- include/ircd/util/typography.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/ircd/util/typography.h b/include/ircd/util/typography.h index 6ea76e6b2..043730873 100644 --- a/include/ircd/util/typography.h +++ b/include/ircd/util/typography.h @@ -227,13 +227,21 @@ ctype(const string_view &s) return ctype(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 +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 bool -valid(const string_view &s) +all_of(const string_view &s) { - return ctype(s) == -1L; + return std::all_of(begin(s), end(s), test); } /// Zero testing functor (work in progress)