Perhaps nowhere is this property more appreciated than when the strings manipulated in your code will change in size, but when you don't know big the change is. I've been working too hard. Note the ease with which we changed the size of the storage allocated to the string. The exact fashion in which the string member functions will allocate space for your data is dependent on the implementation of the library. When one implementation was tested with the example above, it appeared that reallocations occurred on even word boundaries, with one byte held back.
Space grows and existing characters politely move over to accommodate the new elements.
Sometimes, however, this might not be what you want to happen. I have been working too hard. If replace doesn't find the search string, it returns npos . You may have been hunting through this chapter trying to do something relatively simple like replace all the instances of one character with a different character. The answer comes in observing that the string class doesn't solve all these problems alone.