Re: CString help
- From: "Doug Harrison [MVP]" <dsh@xxxxxxxx>
- Date: Sat, 23 Jun 2007 12:11:43 -0500
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
.
- Follow-Ups:
- Re: CString help
- From: Mihai N.
- Re: CString help
- References:
- CString help
- From: jp2code
- Re: CString help
- From: Ajay Kalra
- Re: CString help
- From: jp2code
- Re: CString help
- From: David Wilkinson
- Re: CString help
- From: Mihai N.
- Re: CString help
- From: Doug Harrison [MVP]
- Re: CString help
- From: Mihai N.
- CString help
- Prev by Date: Re: How to allcate an array of strings dynamically
- Next by Date: Re: MFC training, 9th - 11th July 2007, London, UK
- Previous by thread: Re: CString help
- Next by thread: Re: CString help
- Index(es):
Relevant Pages
|