[circular_buffer] why does the copy constructor not copy capacity

Hello, I've been finding the circular_buffer library very helpful (thanks for a great lib!), but recently found the following behavior surprising (this is using a recent svn trunk, if it matters): boost::circular_buffer<int> one(3); boost::circular_buffer<int> two(one); std::cout<<one.capacity()<<std::endl; // outputs 3 std::cout<<two.capacity()<<std::endl; // outputs 0, I was expecting 3 Why does the copy constructor not copy the capacity? It seems like capacity is an essential property of circular_buffer, and as such I'd expect it to be copied as a part of copy construction. I'm sorry if this rationale is covered somewhere, I looked but couldn't find anything. If there isn't a strong reason, would it be possible to change this behavior in the implementation? (it would still satisfy the stated postcondition in the documentation, AFAICT, except the complexity would change to be linear in the capacity) Thanks, Stjepan

On Wed, Apr 23, 2008 at 1:22 PM, Stjepan Rajko <stipe@asu.edu> wrote:
Hello,
I've been finding the circular_buffer library very helpful (thanks for a great lib!), but recently found the following behavior surprising (this is using a recent svn trunk, if it matters):
boost::circular_buffer<int> one(3); boost::circular_buffer<int> two(one);
std::cout<<one.capacity()<<std::endl; // outputs 3 std::cout<<two.capacity()<<std::endl; // outputs 0, I was expecting 3
Why does the copy constructor not copy the capacity? It seems like capacity is an essential property of circular_buffer, and as such I'd expect it to be copied as a part of copy construction.
After looking at the code, it looks like this is a bug. I submitted a ticket with a guess at a patch: http://svn.boost.org/trac/boost/ticket/1852 Stjepan
participants (1)
-
Stjepan Rajko