
On Sat, Nov 24, 2012 at 8:42 AM, Yakov Galka <ybungalobill@gmail.com> wrote:
fundamental? hardly. std::string is not guaranteed to be null terminated.
Guaranteed (almost) since C++11. c_str() and data() now *mean the same thing*,
Really? Got a reference for that?
and s[s.size()] returned null even in C++03.
Is that defined behaviour? You're essentially dereferencing end().
The only thing that is not guaranteed is that *(&s[0] + s.size()) is null. Anyway the point is that you can retrieve a null terminated string from std::string in constant time, without copying anything. So it is practically null terminated.
True, but that's std::string. Not all strings are std::string. " A string_ref that's not required to be null-terminated is far more useful." still holds. -- Olaf