Why I (Still) Won't Use D
Janice Caron
caron800 at googlemail.com
Fri Mar 28 06:25:15 PDT 2008
On 28/03/2008, Michel Fortin <michel.fortin at michelf.com> wrote:
> std::string is null terminated in its memory representation;
No, that's an implementation detail. It's not guaranteed by the C++
standard. All that is guaranteed is that std::string::c_str() must
return a null-terminated char array. The standard does not mandate how
that happens, however.
In particular, the following is not legal
std::string s = "hello";
char c = s[5];
There is no guarantee that c will be assigned '\0'. (although it will
probably work anyway).
More information about the Digitalmars-d
mailing list