Why I (Still) Won't Use D

Sean Kelly sean at invisibleduck.org
Tue Apr 1 09:11:27 PDT 2008


== Quote from Don Clugston (dac at nospam.com.au)'s article
> 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.
> >
> > No one ever used vector<char> as a string and no one ever will.
> "If you are running in a multithreaded environment where you've determined that
> string's reference counting support is a performance problem... consider using
> vector<char> instead of string." -- Scott Meyers, "Effective STL", p 65.

It's also quite handy in instances where a writeable char ptr must be passed
to a C function:

    std::vector<char> buf( SIZE );
    strcpy( &buf[0], "hello, world!" );

Can't do that with std::string, and using new[]/delete[] isn't exception safe.


Sean



More information about the Digitalmars-d mailing list