Re: CString help



On Sat, 23 Jun 2007 01:35:24 -0700, "Mihai N." <nmihai_year_2000@xxxxxxxxx>
wrote:

&s[0]
...
Though not guaranteed, I don't know any implementation where this won't
work.

Possible, but implementation speciffic.
Since it is not captured in the standard in any way, it can disapear at any
time.

Which is why I said:

I'd really like the non-contiguity, reference-counted, etc options to just
go away. People who need those things can't do without them, and the
possibility they exist complicates things for everyone else.

Again, I don't know of any implementation of std::string for which it won't
work, and I expect there would be tremendous resistance to breaking that
sort of code. Furthermore, I bet I can find other non-portable use of
std::string in most every program that makes non-trivial use of it. With at
least 2^4 possible implementations, it's a near certainty.

On a happy note, it appears the contiguity assumption will finally be made
a requirement (note well the rationale, in particular its last sentence):

530. Must elements of a string be contiguous?
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#530

I'm happy to learn of that, but my argument has always been that it's crazy
for a "basic" string to have upwards of 2^4 possible implementations with
wildly difference behavior and performance. Sometimes, too much freedom is
a bad thing, and it's clearly the case here. A basic_string ought to be
"basic", and someone needing a "fancy" string is well-advised to use one
that guarantees the things he requires.

(and in fact I think I know a case where this might break: flex_string of
Andrei Alexandrescu, a very nice string class, standard compliant).

But flex_string != std::basic_string. I skimmed the DDJ article here:

http://www.ddj.com/dept/cpp/184403784

I see Andrei talked at length about "Standard-compliant" and COW. The
problem is, the two aren't compatible, at least if you think
"copy-on-write" actually means "copy-on-write".

--
Doug Harrison
Visual C++ MVP
.



Relevant Pages

  • Re: Why is it dangerous?
    ... learn that C had such weak string handling, ... Exploiting getson an auto buffer ... that omitted any standard on what could or could not be input. ... the pedants, on whose code contains more *actual* bugs. ...
    (comp.lang.c)
  • Re: Anyone object to the following change in libc?
    ... sscanfinput string. ... ISO C standard" refers to "c89", which is the version of the C ... non-sensical format specifier entirely, since any characters that ... conformance test suite for ISO C complaining about the ...
    (freebsd-current)
  • Re: A C++ Whishlist
    ... > people from inclusion in a standard. ... > creating their own string class. ... >>don't want an ever increasing size of exception specification on each ...
    (comp.lang.cpp)
  • Re: How to make Forth interesting?
    ... Standard Forth doesn't give you all the tools to do that. ... thought here is to set up some new wordlists whose hash function is the ... John Passaniti says if you have a language that's ... it might be useful to have more string stuff in Forth. ...
    (comp.lang.forth)
  • Re: string comparison
    ... Null termination is part of the definition of a string. ... of the Standard, or did you mean horribly designed? ... then why trust that the assembler will generate the ... Do you check the machine code to see if the ...
    (comp.lang.c)