aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.util/ctype.ccm
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-07-01 17:07:04 +0100
committerLexi Winter <lexi@le-fay.org>2025-07-01 17:07:04 +0100
commit2e2d1bd3b6c7776b77c33b94f30ead89367a71e6 (patch)
tree54d37ffadf8e677938d9b7a28e4e9b71be1e75c1 /nihil.util/ctype.ccm
parent36427c0966faa7aecd586b397ed9b845f18172f5 (diff)
downloadnihil-2e2d1bd3b6c7776b77c33b94f30ead89367a71e6.tar.gz
nihil-2e2d1bd3b6c7776b77c33b94f30ead89367a71e6.tar.bz2
add nihil.std
Diffstat (limited to 'nihil.util/ctype.ccm')
-rw-r--r--nihil.util/ctype.ccm73
1 files changed, 29 insertions, 44 deletions
diff --git a/nihil.util/ctype.ccm b/nihil.util/ctype.ccm
index 6d30c4f..8f5de27 100644
--- a/nihil.util/ctype.ccm
+++ b/nihil.util/ctype.ccm
@@ -1,14 +1,8 @@
-/*
- * This source code is released into the public domain.
- */
-
-module;
-
-#include <concepts>
-#include <locale>
-
+// This source code is released into the public domain.
export module nihil.util:ctype;
+import nihil.std;
+
namespace nihil {
/*
@@ -21,15 +15,16 @@ namespace nihil {
* ctype_is copies the locale, so passing a temporary is fine.
*/
-export struct ctype_is final {
- ctype_is(std::ctype_base::mask mask_,
- std::locale const &locale_ = std::locale())
- : m_mask(mask_)
- , m_locale(locale_)
- {}
+export struct ctype_is final
+{
+ explicit ctype_is(std::ctype_base::mask mask_,
+ std::locale const &locale_ = std::locale()) noexcept
+ : m_mask(mask_)
+ , m_locale(locale_)
+ {
+ }
- [[nodiscard]] auto operator()(this ctype_is const &self,
- std::integral auto c)
+ [[nodiscard]] auto operator()(this ctype_is const &self, std::integral auto c)
{
using ctype = std::ctype<decltype(c)>;
auto &facet = std::use_facet<ctype>(self.m_locale);
@@ -37,11 +32,11 @@ export struct ctype_is final {
}
private:
- std::ctype_base::mask m_mask;
- std::locale m_locale;
+ std::ctype_base::mask m_mask;
+ std::locale m_locale;
};
-// Predefined tests for the current global locale.
+// Predefined tests for the current global locale.
export inline auto is_space = ctype_is(std::ctype_base::space);
export inline auto is_print = ctype_is(std::ctype_base::print);
@@ -59,29 +54,19 @@ export inline auto is_graph = ctype_is(std::ctype_base::graph);
// Predefined tests for the C locale. The C locale is guaranteed to always be
// available, so this doesn't create lifetime issues.
-export inline auto is_c_space =
- ctype_is(std::ctype_base::space, std::locale::classic());
-export inline auto is_c_print =
- ctype_is(std::ctype_base::print, std::locale::classic());
-export inline auto is_c_cntrl =
- ctype_is(std::ctype_base::cntrl, std::locale::classic());
-export inline auto is_c_upper =
- ctype_is(std::ctype_base::upper, std::locale::classic());
-export inline auto is_c_lower =
- ctype_is(std::ctype_base::lower, std::locale::classic());
-export inline auto is_c_alpha =
- ctype_is(std::ctype_base::alpha, std::locale::classic());
-export inline auto is_c_digit =
- ctype_is(std::ctype_base::digit, std::locale::classic());
-export inline auto is_c_punct =
- ctype_is(std::ctype_base::punct, std::locale::classic());
-export inline auto is_c_xdigit =
- ctype_is(std::ctype_base::xdigit, std::locale::classic());
-export inline auto is_c_blank =
- ctype_is(std::ctype_base::blank, std::locale::classic());
-export inline auto is_c_alnum =
- ctype_is(std::ctype_base::alnum, std::locale::classic());
-export inline auto is_c_graph =
- ctype_is(std::ctype_base::graph, std::locale::classic());
+//NOLINTBEGIN: Technically, std::locale::classic() can throw. Assume it doesn't.
+export inline auto is_c_space = ctype_is(std::ctype_base::space, std::locale::classic());
+export inline auto is_c_print = ctype_is(std::ctype_base::print, std::locale::classic());
+export inline auto is_c_cntrl = ctype_is(std::ctype_base::cntrl, std::locale::classic());
+export inline auto is_c_upper = ctype_is(std::ctype_base::upper, std::locale::classic());
+export inline auto is_c_lower = ctype_is(std::ctype_base::lower, std::locale::classic());
+export inline auto is_c_alpha = ctype_is(std::ctype_base::alpha, std::locale::classic());
+export inline auto is_c_digit = ctype_is(std::ctype_base::digit, std::locale::classic());
+export inline auto is_c_punct = ctype_is(std::ctype_base::punct, std::locale::classic());
+export inline auto is_c_xdigit = ctype_is(std::ctype_base::xdigit, std::locale::classic());
+export inline auto is_c_blank = ctype_is(std::ctype_base::blank, std::locale::classic());
+export inline auto is_c_alnum = ctype_is(std::ctype_base::alnum, std::locale::classic());
+export inline auto is_c_graph = ctype_is(std::ctype_base::graph, std::locale::classic());
+//NOLINTEND
} // namespace nihil