Originally Posted by
matsp
Of course - my point was more that UNLESS YOU KNOW the implementation, you can't know if the string is allocated or not. Small buffer optimization is an implementation that doesn't allocate storage for an empty string. Another option for the empty string is to not have a string stored at all - simply by the fact that the length is zero.
My example, by the way, is not necessarily how it is implemented in ANY version of std::string - but since there is no clear statement of how it should be implemented, we can't determine what it does in the empty constructor example, or in any other constructor for that matter, and whether that will lead to an exception or not.
--
Mats