boostorg / container

STL-like containers from Boost
http://www.boost.org/libs/container/
Boost Software License 1.0
96 stars 116 forks source link

flat_set and friends should offer a `const sequence_type& sequence() const` method to view the underlying sequence #221

Closed RedBeard0531 closed 2 years ago

RedBeard0531 commented 2 years ago

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.

igaztanaga commented 2 years ago

Thanks for the suggestion, it looks really useful and we already expose sequence_type through extract_sequence and adopt_sequence.