gcc-2.95 and SGI STL 3.2

Steinar Bang sb@metis.no
Tue Jun 22 00:01:00 GMT 1999


>>>>> dvv@dvv.ru (Dima Volodin):

> On Mon, 21 Jun 1999 09:09:42 +0100 (GMT), you wrote:
>> On 21 Jun 1999, Steinar Bang wrote:
>> 
>>> The native g++ <string> uses refcounting.  The SGI STL <string> always
>>> does a deep copy.

>> I don't think refcounting actually helps much with strings -- you
>> have to do a deep copy whenever the data is accessed anyway (even
>> read: think 'string s="str",t; char &c=s[0];').

> Besides, in a multi-threaded environment, refcounting requires an
> extra mutex,...

There's an article by Herb Sutter in the june 1999 issue of the C/C++
Users Journal
        http://www.cuj.com/archive/1706/
(no online version of the article, unfortunately), that addresses
refcounting in a multithreaded world.  It uses something called
"atomic integer operations" to do thread-safe refcounting at a lower
cost than mutex operations.

But as I understand it, these operations may not be available on all
systems, and if they are, may have different interfaces.


More information about the Gcc mailing list