@@ -143,6 +143,20 @@ class BasicStringClassifier
143
143
*/
144
144
static constexpr bool is_x_digit (char_type ch);
145
145
146
+ /* *
147
+ * Checks if the given character is a whitespace character as classified by the default C
148
+ * locale.
149
+ *
150
+ * The STL's std::isspace and std::iswspace require that the provided character fits into an
151
+ * unsigned char and unsigned wchar_t, respectively. Other values result in undefined behavior.
152
+ * This method has no such restriction.
153
+ *
154
+ * @param ch The character to classify.
155
+ *
156
+ * @return True if the character is a whitespace character.
157
+ */
158
+ static constexpr bool is_space (char_type ch);
159
+
146
160
private:
147
161
/* *
148
162
* Remove the 0x20 bit from the given character, effectively converting the a-z range of
@@ -161,6 +175,12 @@ class BasicStringClassifier
161
175
static constexpr const auto s_upper_f = FLY_CHR(char_type, ' F' );
162
176
static constexpr const auto s_lower_a = FLY_CHR(char_type, ' a' );
163
177
static constexpr const auto s_lower_z = FLY_CHR(char_type, ' z' );
178
+ static constexpr const auto s_space = FLY_CHR(char_type, ' ' );
179
+ static constexpr const auto s_form_feed = FLY_CHR(char_type, ' \f ' );
180
+ static constexpr const auto s_line_feed = FLY_CHR(char_type, ' \n ' );
181
+ static constexpr const auto s_carriage_return = FLY_CHR(char_type, ' \r ' );
182
+ static constexpr const auto s_horizontal_tab = FLY_CHR(char_type, ' \t ' );
183
+ static constexpr const auto s_vertical_tab = FLY_CHR(char_type, ' \v ' );
164
184
165
185
static constexpr const auto s_case_bit = static_cast <int_type>(0x20 );
166
186
static constexpr const auto s_case_mask = static_cast <int_type>(~s_case_bit);
@@ -251,6 +271,14 @@ constexpr inline bool BasicStringClassifier<StringType>::is_x_digit(char_type ch
251
271
return is_digit (ch) || ((alpha >= s_upper_a) && (alpha <= s_upper_f));
252
272
}
253
273
274
+ // ==================================================================================================
275
+ template <typename StringType>
276
+ constexpr inline bool BasicStringClassifier<StringType>::is_space(char_type ch)
277
+ {
278
+ return (ch == s_space) || (ch == s_form_feed) || (ch == s_line_feed) ||
279
+ (ch == s_carriage_return) || (ch == s_horizontal_tab) || (ch == s_vertical_tab);
280
+ }
281
+
254
282
// ==================================================================================================
255
283
template <typename StringType>
256
284
constexpr inline auto BasicStringClassifier<StringType>::unify_az_characters(char_type ch)
0 commit comments