I have a use case where I need to expose a const vector<T>& accessor because the existing implementation just holds a plain vector<T>, but would also like to switch to a set-like type because the data is already guaranteed to be sorted. I was surprised that I couldn't just use flat_set for this because it does not offer a read-only view into the underlying sequence.
It already is documented that the iterator type for flat_set must be the same as the underlying sequence, so its not like this is opening a new hole in the abstraction.
I have a use case where I need to expose a
const vector<T>&
accessor because the existing implementation just holds a plainvector<T>
, but would also like to switch to a set-like type because the data is already guaranteed to be sorted. I was surprised that I couldn't just useflat_set
for this because it does not offer a read-only view into the underlying sequence.It already is documented that the iterator type for
flat_set
must be the same as the underlying sequence, so its not like this is opening a new hole in the abstraction.