I want to convert a std::string
to lowercase. I am aware of the function tolower()
, however in the past I have had issues with this function and it
My own template functions which performs upper / lower case.
#include
#include
//
// Lowercases string
//
template
std::basic_string lowercase(const std::basic_string& s)
{
std::basic_string s2 = s;
std::transform(s2.begin(), s2.end(), s2.begin(), tolower);
return std::move(s2);
}
//
// Uppercases string
//
template
std::basic_string uppercase(const std::basic_string& s)
{
std::basic_string s2 = s;
std::transform(s2.begin(), s2.end(), s2.begin(), toupper);
return std::move(s2);
}