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?

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

As it happens, this is precisely the example given for std::transform on cppreference: en.cppreference.com/w/cpp/algorithm/transform

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.