Subject: Re: [boost] [utility] new auto_buffer class --- RFC
From: David Abrahams (dave_at_[hidden])
Date: 2009-03-14 00:08:33
On Mar 3, 2009, at 1:45 AM, Thorsten Ottosen wrote:
> Steven Watanabe skrev:
>> Thorsten Ottosen wrote:
>>>> Certainly swap should be provided somehow; a fast-as-possible
>>>> swap is
>>>> not otherwise possible since the user can't get at the buffer
>>>> boost::array supports swap, and yours should be at least as fast as
>>>> that. On that precedent I'd say you should support swap() under
>>>> name. Has anyone ever complained about the deceptive slowness of
>>>> boost::array's swap?
>>> I don't know. I just stay clear of it. The point is that we don't
>>> inexperienced users to use an O(n) swap accidently.
>> Please define n.
> n would be c.size()
I'm sorry, I know this will sound harsh, but I don't know how else to
say it: we went down this road with ptr_container, and should not
repeat that mistake. The instinct to protect naive users from
performance pitfalls by leaving out fundamental operations (swap in
this case; assignment and copy in the case of ptr_container) is just
wrong. That's especially true when the implementations would NOT
violate the efficiency guarantees required by the concepts.
Let me also point out that std::array will support swap for C++0x (by
swapping individual elements).
-- David Abrahams BoostPro Computing http://boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk