Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-07-23 05:31:25


Pavel Vozenilek wrote:
> "Jan Gaspar" <jga_at_[hidden]> wrote in message
> news:3F1E52B9.7E50FE9_at_whitestein.com...
>> I think, I changed mind. The flatten() method can be substituted by
>> something like this:
>>
>> void doSomething(const int* pInt, size_t numInts); // C API
>> circular_buffer<int> intBuffer(10);
>> ...
> //
>> fill the buffer somehow
>> vector<int> v(intBuffer.begin(), intBuffer.end()); // copy
>> if (!v.empty()) doSomething(&v[0], v.size()); // pass the
>> data to
> the API
>>
>> // &v[0] < &v[1] < ... < &v[n]
>>
>> I think, we should rather keep the interface minimal.
>>
> Yes but flatten() may be much more efficient, in some cases it may
> involve less or no copying at all and memory consumption won't be
> size() + capacity().

I suggest

T * circular_buffer<T>::data();

Postcondition: The elements of *this are now in the range [ r, r + size() ),
where r is the return value. Non-const operations on *this (except data())
may invalidate r.


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