Skip to content

Commit c12ba5f

Browse files
committed
#61- Implement method is_words_sep
Completed. Fixed signature on a fex other methods.
1 parent f28a337 commit c12ba5f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

cpp-strings/cppstrings.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ 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() noexcept
112+
inline const bool is_punctuation() const noexcept
113113
{
114114
return this->length() == 1 && is_punctuation((*this)[0]);
115115
}
@@ -128,7 +128,7 @@ class CppStringT : public std::basic_string<CharT>
128128
* in the Unicode character database, either its general category is Zs
129129
* (“Separator, space”), or its bidirectional class is one of WS, B, or S.
130130
*/
131-
inline const bool is_space() noexcept
131+
inline const bool is_space() const noexcept
132132
{
133133
if (this->length() == 0)
134134
return false;
@@ -145,6 +145,19 @@ class CppStringT : public std::basic_string<CharT>
145145
}
146146

147147

148+
//--- is_words_sep ------------------------------------
149+
/** \brief Returns true if there are only whitespace and punctuation characters in the string and there is at least one character, or false otherwise. */
150+
inline const bool is_words_sep() const noexcept
151+
{
152+
return is_space() || is_punctuation();
153+
}
154+
155+
/** \brief Returns true if character belongs to ASCII spaces or punctuation sets. */
156+
static inline const bool is_words_sep(const value_type& ch) noexcept
157+
{
158+
return is_space(ch) || is_punctuation(ch);
159+
}
160+
148161

149162
protected:
150163

0 commit comments

Comments
 (0)