Devolus
Devolus

Reputation: 22094

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?

Upvotes: 0

Views: 660

Answers (1)

Stack Overflow is garbage
Stack Overflow is garbage

Reputation: 248129

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

Upvotes: 3

Related Questions