By experiment, it seems CStringT::MakeReverse
and CStringT::MakeUpper
all change the string in-place.
What is the keyword on CStringT
Class documentation, which I should pay attention to, saying these operations are "in-place"?
Returning a value implies the methods create new copies in my newbie's opinion.
Collecting the good points mentioned in the comments above:
There are several points in the CStringT
documentation that give hints that the methods are mutating the current object in place:
The main hint is that the methods return a reference - CStringT&
.
If they were creating a new object it would have been returned by value.
There is no other object which it make sense to return a refernce to here, execpt for the current one.
Additional points that supports this:
The methods are not marked as const
. Although it is not a must, methods that do not modify the object should be marked as const
, and the lacking of it hints that these methods do modify it.
The name of the methods starting with Make
usually hint that they modify the current object to "make" it something else.
The documentation text, e.g. "Reverses the order of the characters in the CStringT object." hints that the current object will be modified.