|
JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
|
Character-semantics concept and utilities — constexpr-safe character classification and transformation for 1-byte fundamental types. More...
Go to the source code of this file.
Namespaces | |
| namespace | jh::meta |
| Aggregated entry point for compile-time metaprogramming utilities. | |
Concepts | |
| concept | jh::meta::any_char |
| Concept representing character-semantic 1-byte integral types. | |
Character-semantics concept and utilities — constexpr-safe character classification and transformation for 1-byte fundamental types.
This header defines jh::meta::any_char, a C++20 concept identifying the core 1-byte character types (char, signed char, unsigned char), together with a small constexpr-safe classification and transformation toolkit for character operations.
The any_char concept constrains type parameters to only those built-in 1-byte integral character types directly usable for raw text or binary data. This design ensures type purity, constexpr safety, and clear separation from UTF-8 and byte-level abstractions.
is_alpha() — check for alphabetic characters (A-Z, a-z). is_digit() — check for decimal digits (0-9). is_alnum() — check for alphanumeric (letter or digit). is_hex_char() — check for valid hexadecimal characters (0-9, A-F, a-f). is_base64_core() — check if part of the standard Base64 alphabet (A-Z, a-z, 0-9, '+', '/'). is_base64url_core() — check if part of the Base64URL alphabet (A-Z, a-z, 0-9, '-', '_'). is_ascii() — verify whether a character is within the 7-bit ASCII range (0-127). is_printable_ascii() — check if character is a printable 7-bit ASCII symbol (32-126 inclusive). is_valid_char() — check that character is not a control or DEL (returns true for all non-control bytes). to_upper() — convert a letter to uppercase; leave others unchanged. to_lower() — convert a letter to lowercase; leave others unchanged. flip_case() — invert alphabetic case. any_char constraint rejects higher-level or incompatible types such as char8_t, std::byte, and bool. remove_cvref usage: The concept explicitly expects the raw type form — it models the prototype of character semantics. cv-qualifiers (e.g. const Char) can be manually specified if needed. References are intentionally excluded because Char is a metaprogramming token rather than a forwarding type; templates like template<any_char Char> instantiate with copies, not references, preserving constexpr safety. sizeof(T) == 1 and avoids UB across translation units when hashing or reinterpreting raw data. 1.3.x
2025