|
Boost : |
Subject: Re: [boost] [utility] new auto_buffer class --- RFC
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2009-03-14 04:42:46
David Abrahams skrev:
>
> On Mar 3, 2009, at 1:45 AM, Thorsten Ottosen wrote:
>
>> Steven Watanabe skrev:
>>> AMDG
>>> 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 pointer.
>>>>> 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 that
>>>>> 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 want
>>>> 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.
ptr_containers have been copy-constrictible, and assignable is some
releases now.
>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.
I have provided a swap(), see the thread "[utility] auto_buffer v2".
But a linear size() can be problematic, so can a linear swap().
> Let me also point out that std::array will support swap for C++0x (by
> swapping individual elements).
Ok. Somebody should add it to boost::array then.
-Thorsten
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk