
"Pavel Vozenilek" <pavel_vozenilek@hotmail.com> writes:
"David Abrahams" <dave@boost-consulting.com> wrote
object pushed out of circular_buffer because container got full must be destroyed.
Why? I mean, the only reason I can see for that requirement is an aesthetic one. I don't see any logical foundation for the assertion.
I am not getting something. You are saying objects can go away without being destructed?
No, I'm saying that their values can go away without destruction: you could replace their values in the buffer using assignment instead of destroy + construct. There's no a priori reason they have to be destroyed. When I erase objects from a std::vector, the objects being erased don't neccessarily get destroyed. They may be assigned. For example, here's STLPort's vector<T>::erase(iterator) implementation: iterator erase(iterator __position) { if (__position + 1 != end()) __copy_ptrs(__position + 1, this->_M_finish, __position, _TrivialAss()); --this->_M_finish; _Destroy(this->_M_finish); return __position; } Notice that only the last element of the vector is destroyed. -- Dave Abrahams Boost Consulting www.boost-consulting.com