Why I (Still) Won't Use D
Michel Fortin
michel.fortin at michelf.com
Fri Mar 28 05:58:10 PDT 2008
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.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list