Boost logo

Boost :

From: Jan Gaspar (jga_at_[hidden])
Date: 2003-08-22 08:55:13


Hi all!

Another beast was born. You can find it at
http://groups.yahoo.com/group/boost/files/circular_buffer.zip

New features:
- Added circular_buffer_space_optimized adaptor + documentation.
- Introduced circular_buffer<T>::data() method.
- Updated documentation (including source code documentation).
- Bug fixes.

Some comments:

> 1. IMO the macro based exception handling isn't needed, it is better
> to use RAII, like:
> ...
>
> can be replaced by:
>
> void set_capacity(size_type new_capacity) {
> if (new_capacity == capacity()) return;
> pointer buff = allocate(new_capacity);
>
> struct deleter_t {
> pointer data;
> size_type capacity;
> deleter_t(pointer p, size_type s) : data(p), capacity(s) {}
> ~deleter_t() { deallocate(data, capacity); }
> };
> deleter_t guard(buff, new_capacity);
>
> size_type new_size = new_capacity < size() ? new_capacity : size();
> std::uninitialized_copy(end() - new_size, end(), buff);
> destroy();
> m_size = new_size;
> m_buff = m_first = buff;
> m_end = m_buff + new_capacity;
> m_last = full() ? m_buff : m_buff + size();
> guard.data = 0;
> }
>
I think this is not a good idea because
- it won't work - the ~deleter_t() destructor does not have access to
the deallocate() method
- the original macros are more explanatory (it is easier to understand)
- every STL implementation is using such macros

> ---------------------------------------------
> I tried (Intel 7):
> circular_buffer aa(10);
> aa.assign(3, 1.0);
>
> and got error:
>

I think it should already compile for both Intel and Borland.

> Internal checks: maybe something like this can be used:
>
Done.

> Small note: the source code contains some tabs. Boost requirement is to use
> spaces only.
>

I forgot. Now should be everything OK.

S pozdravom,

Jano

P.S. I will be on holiday next week.

--
Jan Gaspar | jga_at_[hidden]
Whitestein Technologies | www.whitestein.com
Panenska 28 | SK-81103 Bratislava | Slovak Republic
Tel +421(2)5930-0735 | Fax +421(2)5443-5512

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