C++ Logo

std-discussion

Advanced search

Vector like working with existing ranges - no copy?

From: Julien D Arques <acc.gccquestions_at_[hidden]>
Date: Sun, 5 Jun 2022 14:11:14 +0200
Hi,
Will there be a ring buffer implementation for ranges? Even with an option
to forbid the cycle.
It could be very helpful when working with existing memory (mmap..),
because:
1) the size of the ring would be known in advance
2) the range span is responsibility of the developer
3) the memory management inside the ring could be made easy by vector-like
methods, instead of reinventing the wheel each time
4) no copies
5) setting the head position mimics the deque for fast head/tail
operations. Given the option to disable cycle, we have a nice vector-like
range on which we can work. Insert up to the point the range is completely
filled up. In which case, return false or throw
6) signature example:
auto ranges::modifiable_range(span<Type> range, size_t head_offset, size_t
elements_sets, bool cyclic);
>From there, it is easy to calculate the number of available slots to
insert, and whatever.
I already use my own version of this but Ranges TS are a perfect
opportunity to ask for this to be integrated.

Any insights are welcome,

Thanks,

Received on 2022-06-05 12:11:25