Boost logo

Boost :

Subject: Re: [boost] [utility] new auto_buffer class --- RFC
From: Scott McMurray ([hidden])
Date: 2009-03-15 12:18:37

On 2009-03-15, Thorsten Ottosen <thorsten.ottosen_at_[hidden]> wrote:
> Scott McMurray skrev:
>> Is there really a cost to allowing it, though? I'd assume it would
>> have a vector-like operator= that'd be something like this:
>> copy(other.begin(), other.begin() + size(), begin());
>> if (size() > other.size()) erase(begin()+other.size(), end());
>> else insert(end(), other.begin()+size(), other.end());
> That is not quite how I implemented it, but for operator= the extra
> check is not that important, so I can add it,

I agree that self-assignment is uncommon enough for an explicit check
to be a pessimization, though. Is the algorithm you have ( the
attachment to the first post in this thread doesn't have operator= )
really more efficient than one that doesn't need the explicit check?

Boost list run by bdawes at, gregod at, cpdaniel at, john at