Convert a String In C++ To Upper Case

How could one convert a string to upper case. The examples I have found from googling only have to deal with chars.


#include <algorithm>
#include <string>

std::string str = "Hello World";
std::transform(str.begin(), str.end(),str.begin(), ::toupper);

Boost string algorithms:

#include <boost/algorithm/string.hpp>
#include <string>

std::string str = "Hello World";

boost::to_upper(str);

std::string newstr = boost::to_upper_copy<std::string>("Hello World");

Short solution using C++11 and toupper().

for (auto & c: str) c = toupper(c);