string: add to_upper
This commit is contained in:
parent
d7f9b12f82
commit
595d062638
32
string.hpp
32
string.hpp
@ -19,6 +19,38 @@
|
||||
namespace cruft {
|
||||
std::string to_utf8 (const wchar_t*);
|
||||
std::string to_utf8 (const std::wstring&);
|
||||
|
||||
|
||||
/// Convert the provided string to all upper case
|
||||
inline std::string
|
||||
to_upper (std::string &&val)
|
||||
{
|
||||
std::transform (
|
||||
std::begin (val),
|
||||
std::end (val),
|
||||
std::begin (val),
|
||||
::toupper
|
||||
);
|
||||
return std::move (val);
|
||||
}
|
||||
|
||||
|
||||
/// Convert the provided string to all upper case
|
||||
inline std::string
|
||||
to_upper (std::string const &val)
|
||||
{
|
||||
std::string res;
|
||||
res.reserve (val.size ());
|
||||
|
||||
std::transform (
|
||||
std::begin (val),
|
||||
std::end (val),
|
||||
std::back_inserter (res),
|
||||
::toupper
|
||||
);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user