@@ -109,35 +109,49 @@ class CppStringT : public std::basic_string<CharT>
109109
110110 // --- is_punctuation ----------------------------------
111111 /* * \brief Returns true if the string contains only one character and if this character belongs to the ASCII punctuation set. */
112- inline const bool is_punctuation (const MyBaseClass& str ) noexcept
112+ inline const bool is_punctuation () noexcept
113113 {
114- return str. size == 1 && _ASCII_PUNCT_DATA. contains (str [0 ]);
114+ return this -> length () == 1 && is_punctuation ((* this ) [0 ]);
115115 }
116116
117+ /* * \brief Returns true if character belongs to the ASCII punctuation set. */
118+ static inline const bool is_punctuation (const value_type& ch) noexcept
119+ {
120+ return _ASCII_PUNCT_DATA.contains (ch);
121+ }
122+
123+
117124 // --- is_space ----------------------------------------
118125 /* * \brief Returns true if there are only whitespace characters in the string and there is at least one character, or false otherwise.
119126 *
120127 * Notice for version 2.0 of this library: a character is whitespace if
121128 * in the Unicode character database, either its general category is Zs
122129 * (“Separator, space”), or its bidirectional class is one of WS, B, or S.
123130 */
124- inline const bool is_space (const MyBaseClass& str ) noexcept
131+ inline const bool is_space () noexcept
125132 {
126- if (str. size () == 0 )
133+ if (this -> length () == 0 )
127134 return false ;
128- for (auto & c : str )
129- if (std::find (_ASCII_SEP. cbegin (), _ASCII_SEP. cend (), c) == _ASCII_SEP. cend ( ))
135+ for (auto & c : * this )
136+ if (! is_space (c ))
130137 return false ;
131138 return true ;
132139 }
133140
141+ /* * \brief Returns true if character belongs to the ASCII spaces set. */
142+ static inline const bool is_space (const value_type& ch) noexcept
143+ {
144+ return _ASCII_SPACES.contains (ch);
145+ }
146+
147+
134148
135149protected:
136150
137151
138152private:
139153 // === DATA ============================================
140154 static inline constexpr std::vector<value_type> _ASCII_PUNCT_DATA{ ' !' , ' ,' , ' .' , ' :' , ' ;' , ' ?' };
141- static inline constexpr std::vector<value_type> _ASCII_SEP { ' ' , ' \t ' , ' \n ' , ' r' , ' \f ' };
155+ static inline constexpr std::vector<value_type> _ASCII_SPACES { ' ' , ' \t ' , ' \n ' , ' r' , ' \f ' };
142156
143157};
0 commit comments