
On 2009-03-15, Thorsten Ottosen <thorsten.ottosen@dezide.com> 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?