@@ -39,75 +39,38 @@ template <typename... Content> struct set {
3939	}
4040};
4141
42+ template  <auto ... Cs> struct  enumeration  : set<character<Cs>...> { };
43+ 
4244template  <typename ... Content> struct  negate  {
4345	template  <typename  CharT> inline  static  constexpr  bool  match_char (CharT value) noexcept  {
4446		return  !(Content::match_char (value) || ... || false );
4547	}
4648};
4749
48- struct  word_chars  {
50+ template  < auto  A,  auto  B>  struct  char_range  {
4951	template  <typename  CharT> CTRE_FORCE_INLINE static  constexpr  bool  match_char (CharT value) noexcept  {
50- 		return  (value >= ' A '  && value <=  ' Z ' ) || (value >=  ' a '   && value <=  ' z ' ) ||  (value >=  ' 0 '  && value  <= ' 9 ' ) || (value ==  ' _ ' 
52+ 		return  (value >= A)  && (value <= B );
5153	}
5254};
5355
54- struct  space_chars  {
55- 	template  <typename  CharT> CTRE_FORCE_INLINE static  constexpr  bool  match_char (CharT value) noexcept  {
56- 		return  value == '  ' ' \t ' ' \n ' ' \v ' ' \f ' ' \r ' 
57- 	}
58- };
56+ using  word_chars = set<char_range<' A' ' Z' ' a' ' z' ' 0' ' 9' ' _' 
5957
60- struct  alphanum_chars  {
61- 	template  <typename  CharT> CTRE_FORCE_INLINE static  constexpr  bool  match_char (CharT value) noexcept  {
62- 		return  (value >= ' A' ' Z' ' a' ' z' ' 0' ' 9' 
63- 	}
64- };
58+ using  space_chars = enumeration<'  ' ' \t ' ' \n ' ' \v ' ' \f ' ' \r ' 
6559
66- struct  alpha_chars  {
67- 	template  <typename  CharT> CTRE_FORCE_INLINE static  constexpr  bool  match_char (CharT value) noexcept  {
68- 		return  (value >= ' A' ' Z' ' a' ' z' 
69- 	}
70- };
60+ using  alphanum_chars = set<char_range<' A' ' Z' ' a' ' z' ' 0' ' 9' 
7161
72- struct  xdigit_chars  {
73- 	template  <typename  CharT> CTRE_FORCE_INLINE static  constexpr  bool  match_char (CharT value) noexcept  {
74- 		return  (value >= ' A' ' F' ' a' ' f' ' 0' ' 9' 
75- 	}
76- };
62+ using  alpha_chars = set<char_range<' A' ' Z' ' a' ' z' 
7763
78- struct  punct_chars  {
79- 	template  <typename  CharT> inline  static  constexpr  bool  match_char (CharT value) noexcept  {
80- 		return  value == ' !' ' "' ' #' ' $' ' %' 
81- 			|| value == ' &' ' \' ' ' (' ' )' ' *' ' ,' 
82- 			|| value == ' -' ' .' ' /' ' :' ' ;' 
83- 			|| value == ' <' ' =' ' >' ' ?' ' @' ' [' 
84- 			|| value == ' \\ ' ' ]' ' ^' ' _' ' `' 
85- 			|| value == ' {' ' |' ' }' ' ~' 
86- 	}
87- };
64+ using  xdigit_chars = set<char_range<' A' ' F' ' a' ' f' ' 0' ' 9' 
8865
89- struct  digit_chars  {
90- 	template  <typename  CharT> CTRE_FORCE_INLINE static  constexpr  bool  match_char (CharT value) noexcept  {
91- 		return  (value >= ' 0' ' 9' 
92- 	}
93- };
66+ using  punct_chars =
67+     enumeration<' !' ' "' ' #' ' $' ' %' ' &' ' \' ' ' (' ' )' ' *' ' ,' ' -' 
68+ 		' .' ' /' ' =' ' ;' ' <' ' =' ' >' ' ?' ' @' ' [' ' \\ ' ' ]' 
69+ 		' ^' ' _' ' `' ' {' ' |' ' }' ' ~' 
9470
95- struct  ascii_chars  {
96- 	template  <typename  CharT> CTRE_FORCE_INLINE static  constexpr  bool  match_char (CharT value) noexcept  {
97- 		return  (value >= ' \x00 ' ' \x7F ' 
98- 	}
99- };
71+ using  digit_chars = char_range<' 0' ' 9' 
10072
101- template  <auto  A, auto  B> struct  char_range  {
102- 	template  <typename  CharT> CTRE_FORCE_INLINE static  constexpr  bool  match_char (CharT value) noexcept  {
103- 		return  (value >= A) && (value <= B);
104- 	}
105- };
106- template  <auto ... Cs> struct  enumeration  {
107- 	template  <typename  CharT> inline  static  constexpr  bool  match_char (CharT value) noexcept  {
108- 		return  ((value == Cs) || ... || false );
109- 	}
110- };
73+ using  ascii_chars = char_range<' \x00 ' ' \x7F ' 
11174
11275}
11376
0 commit comments