diff --git a/string.hpp b/string.hpp index 19e9928d..301b027d 100644 --- a/string.hpp +++ b/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; + } }