1 module nxt.char_traits;
2 
3 /** Is `true` iff `x` is an ASCII character compile-time constant.
4  *
5  * See_Also: `std.ascii.isASCII`.
6  *
7  * TODO: Extend to array of chars.
8  */
9 enum isASCII(char x) = x < 128;
10 enum isASCII(wchar x) = x < 128;
11 enum isASCII(dchar x) = x < 128;
12 
13 ///
14 @safe pure nothrow @nogc unittest
15 {
16     static assert(isASCII!'a');
17     static assert(!isASCII!'ä');
18 
19     immutable ch = 'a';
20     static assert(isASCII!ch);
21 
22     const cch = 'a';
23     static assert(isASCII!cch);
24 
25     const wchar wch = 'a';
26     static assert(isASCII!wch);
27 
28     const wchar wch_ = 'ä';
29     static assert(!isASCII!wch_);
30 
31     const dchar dch = 'a';
32     static assert(isASCII!dch);
33 
34     const dchar dch_ = 'ä';
35     static assert(!isASCII!dch_);
36 }