Search code examples
c++stdtoupper

std::string ::toupper on the input string


Can I perform a ::toupper transformation on the same string that is the input?

i.e.:

std::transform(s.begin(), s.end(), s.begin(), ::toupper);

or do I need a different target?


Solution

  • Yes. That's legal, and perfectly idiomatic. It's a very common way to do it.