I am reviewing the exception safety of some code and met with some issues about exception safety in string, which I can not find the answer at hand. I think the 3 code segments may all throw exceptions. Because the storage of string internal character data is on heap (using allocator for char?), so when there is low memory, there will be bad_alloc exception?
string str1 = "Hello"; // or string str ("Hello");
3. Empty constructionCode:
string str2 = str1; // str1 is another string object or reference.
I am not quite sure about (3).Code:
thanks in advance,