Boost logo

Boost :

From: Stjepan Rajko (stipe_at_[hidden])
Date: 2008-04-23 16:22:03


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)



Boost list run by bdawes at, gregod at, cpdaniel at, john at