Boost logo

Boost :

Subject: Re: [boost] [utility] new auto_buffer class --- RFC
From: David Abrahams (dave_at_[hidden])
Date: 2009-03-18 08:08:17


on Sun Mar 15 2009, Scott McMurray <me22.ca+boost-AT-gmail.com> wrote:

> On Sun, Mar 15, 2009 at 14:34, Thorsten Ottosen
> <thorsten.ottosen_at_[hidden]> wrote:
>> Scott McMurray skrev:
>>> 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?
>>
>> Here's the current version. I guess I would have to do some test to make
>> 100% sure it's faster.
>>
>
> I would be interested to see if the manual inlining (essentially)
> really does make a noticeable speedup. For small n it wouldn't
> surprise me if it did, though.

It would surprise me.

> The important part, though, is that what you have should work just
> fine for self-assignment. diff will be 0, so you go into the first
> if, pop_back nothing, and then copy over it with itself. So I think
> you actually wrote a self-assignment-safe version without realizing
> it.
>
> ~ Scott
>
> P.S. What kind of exception-throwing limitations are you assuming?
> That (*this).~auto_buffer(); is scary, especially when you don't yet
> have the replacement memory initialized...

Why wouldn't you use copy and swap for that branch?

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk