Skip to content

Commit 9fb272f

Browse files
committed
#55 - Implement method CppStringT::upper()
Completed.
1 parent a45bc56 commit 9fb272f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

cpp-strings/cppstrings.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,32 @@ class CppStringT : public std::basic_string<CharT>
185185
}
186186

187187

188+
//--- upper () -----------------------------------------
189+
/** \brief In-place replaces all characters of the string with their uppercase conversion. Returns a reference to string.
190+
*
191+
* Notice: uses the currently set std::locale, which is the "C" one
192+
* by default or any other one as previously set by the user.
193+
*/
194+
inline CppStringT& upper() noexcept
195+
{
196+
std::transform(this->begin(), this->end(),
197+
this->begin(),
198+
[](value_type ch) { return this->upper(ch); });
199+
return *this;
200+
}
201+
202+
/** \brief Returns uppercase conversion of the character.
203+
*
204+
* Notice: uses the currently set std::locale, which is the "C" one
205+
* by default or any other one as previously set by the user.
206+
*/
207+
static inline const value_type upper(const value_type ch) noexcept
208+
{
209+
return value_type(std::toupper(ch));
210+
}
211+
212+
213+
188214
protected:
189215

190216

0 commit comments

Comments
 (0)