New STL implementation from SGI
Nathan Myers
ncm@cygnus.com
Fri Jul 10 20:04:00 GMT 1998
Pieter Nagel wrote:
>
> On Thu, 9 Jul 1998, Joe Buck wrote:
>
> > Actually I suspect that the SGI version will be slower as well as require
> > more memory in some applications: if copying strings from place to place
> > is common, but concatenation is less common,
>
> Ouch! I've been happily using strings to pass around megabyte-sized
> blobs of data, but reading about the SGI string class makes me want
> to run and reread the spec to check on how portable my use is - I
> thought C++ strings were *supposed* to have reference countng
> semantics.
Unfortunately the (sub-)committee waffled on this issue, and tried to write
the spec to tolerate either implementation, to the detriment of both.
(basic_string<> is easily the least inspiring component in the library.)
If you want a reliably reference-counting string, the "rope" from SGI-STL
might be your best bet. It will be in the rewritten library.
> I'm all for including different implementations of the string class.
> How about renaming basic_string to shallow_copy_basic_string and
> deep_copy_basic_string respectively, and then have a mechanism to
> choose which one is typedefed to basic_string - thereby allowing one
> to write code that uses *both*?
Unfortunately C++ has no aliasing feature for templates. However, it's
possible that basic_string<> could be *derived* from one of the above.
I will look into this; it would require some cooperation from Matt at SGI.
The ideal would be if both could be present at once (though in different
files), but I doubt that is possible in this case.
Nathan Myers
ncm@cantrip.org
More information about the Gcc
mailing list