0

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?

Devolus
  • 21,661
  • 13
  • 66
  • 113

1 Answers1

3

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

jalf
  • 243,077
  • 51
  • 345
  • 550
  • 2
    As it happens, this is precisely the example given for `std::transform` on cppreference: http://en.cppreference.com/w/cpp/algorithm/transform – WhiteViking Oct 11 '15 at 16:49