Why I (Still) Won't Use D

Edward Diener eddielee_no_spam_here at tropicsoft.com
Fri Mar 28 11:51:51 PDT 2008


Michel Fortin wrote:
> On 2008-03-27 18:17:40 -0400, Walter Bright <newshound1 at digitalmars.com> 
> said:
> 
>> Michiel Helvensteijn wrote:
>>> Walter Bright wrote:
>>>
>>>> making for 18 character types! Next, we have char[], vector<char>, and
>>>> string<char>, making for 54 string types, more than half of which are
>>>> implementation defined.
>>>
>>> vector<char> is a silly example and you know it. You could have made 
>>> your
>>> point just fine with only 36 string types. :-)
>>
>> No, I don't agree that it is a silly example. Why is a string 
>> *fundamentally* different from an array? I believe it is a serious 
>> mistake to have both.
> 
> std::string is null terminated in its memory representation; that's why 
> you can call s.c_str() and have a char * that lives as long as you don't 
> cause the string to reallocate. So basically, std::string can be freely 
> converted to a C string if you need one. With std::vector and others you 
> don't have that.

There is no guarantee in the C++ standard that std::string is 
null-terminated in its memory representation.



More information about the Digitalmars-d mailing list