Boost logo

Boost :

From: Jan Gaspar (jga_at_[hidden])
Date: 2003-08-04 04:22:44

Hi Pavel,
I agree with most of your comments.

> 2. in function cb_iterator::operator -(), shouldn't it be std::less instead
> of less? (actually I do not see why < isn't enough here).

I call less() just because efficiency reasons. If I called operator < it would
result in unnecessary calls to create_internal_iterator().

> 5. Similarly in circular_buffer::allocate(). (I wonder where
> std::length_error
> does come from?)

The STL delivered with MSVC7 does it like this. In your opinion what should it

Once again unused space overhead. What about this adaptor?

template <class T> class Adaptor {
    typedef typename circular_buffer<T>::iterator iterator;
    typedef typename circular_buffer<T>::size_type size_type;
 size_type m_final_capacity;
    circular_buffer<T> m_buff;
    Adaptor(size_type capacity) : m_final_capacity(capacity), m_buff(1) {}

    iterator begin() { return m_buff.begin(); }
    iterator end() { return m_buff.end(); }
    size_type size() const { return m_buff.size(); }
    size_type capacity() const { return m_final_capacity; }
    T& operator [] (size_type index) { return m_buff[index]; }

 void push_back(const T& item) {

 iterator insert(iterator pos, const T& item) {
  return m_buff.insert(pos, item);
 void check_capacity() {
  if (m_buff.full() && m_buff.size() < m_final_capacity) {
   size_type new_capacity = m_buff.size() * 2;
   if (new_capacity > m_final_capacity)
    new_capacity = m_final_capacity;


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