Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-03-08 18:42:55


"Pavel Vozenilek" <pavel_vozenilek_at_[hidden]> writes:

> "David Abrahams" <dave_at_[hidden]> wrote
>
>> I still see no a priori reason that circular_buffer must do element
>> destruction before it is itself destroyed. std::vector *has* to do
>> some destruction in order to get the right semantics. Arguably,
>> circular_buffer does not. If it doesn't matter *which* vector
>> elements get destroyed upon erase, then I presume it doesn't matter
>> which circular_buffer elements get destroyed. In that case, why
>> should it matter that any elements are destroyed?
>>
> If you have class and the class has static member keeping
> number of object instances alive (incremented in constructor,
> decremented in destructor):
>
> - putting these objects into vector keeps counter valid,
> - circular_buffer with assignement won't.

I can't understand this claim. If the counter works properly, then it
will stay valid. Assignment doesn't magically make instances appear
or disappear. In one case you assign and the counter doesn't
change. In the other you destroy one element and construct another
in its place and the counter is incremented, then decremented.

> That was problem I did have with earlier version of
> circular_buffer and that' why I did ask for construct/destruct
> feature.
>
> It is maybe border case but IMHO valid one against assignement.

I don't get it.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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