Boost logo

Boost :

From: Hans Dembinski (hans.dembinski_at_[hidden])
Date: 2019-09-10 09:30:30

> On 10. Sep 2019, at 01:32, Gavin Lambert via Boost <boost_at_[hidden]> wrote:
> On 9/09/2019 19:43, Hans Dembinski wrote:
>> It looks like circular span can adapt any suitable STL container into a circular one. In fact, circular array and vector are implemented by inheriting privately from std::array and circular::span, which is nice. However, wouldn't it be more general to provide a circular_adaptor, which works with any vector or array, and perhaps even any STL container? Perhaps someone wants a circular set?
> I'm curious what you mean by that.
> Circularity implies the ability to do random indexing (on the underlying container, even if hiding this from consumers), thus it should in principle be compatible with any container that produces random access iterators -- including array and vector, but not including set.
> How would you imagine a "circular set" working?

It probably doesn't make much sense. I didn't really think a lot about it, but in my defence, there are set implementations with random access iterators, namely boost::flat_set.

The main point of my suggestion was rather (as explained in a private email to Bjorn), that it may be better if the convenience classes circular::vector and circular::array are not hard-wired to use std::vector and std::array, but that the adapted container is a template parameter. There are other vector and array implementations that people may want to use, boost::vector and boost::static_vector come to mind.

The circular::vector template could look like this:

template <class T, class AdaptedContainer = std::vector<T>>
class vector : private AdaptedContainer, private circular::span<T> { … }

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