|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-06-01 16:03:53
Alexander Terekhov wrote:
> Peter Dimov wrote:
>>
>> Alexander Terekhov wrote:
>>
>>> Yeah, simply put, mutations of std::string object may invalidate
>>> references and iterators (with COW inspired semantics for non-
>>> const operator[]() et al. )... threads or no threads, COW or no
>>> COW.
>>
>> Umm, not exactly.
>>
>> int x = s[0];
>>
>> (with non-const s) does not invalidate if COW isn't used,
>
> Uhmm, that's not what the standard says.
I know what the standard says. ;-) It's still true. An uncounted string, a
vector<> and an ordinary array do not invalidate and do not "write" when the
above is used. COW is visible because it changes the semantics of a
"non-const read".
My point was that a COW-friendly class should have had
class cow_friendly_string
{
public:
char get( int i ) const;
void set( int i, char ch );
};
sidestepping the above problem.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk