Boost logo

Boost :

Subject: Re: [boost] [container] moving a pre-built vector into a flat_set
From: Glen Fernandes (glen.fernandes_at_[hidden])
Date: 2017-03-12 16:18:55


On Sun, Mar 12, 2017 at 7:22 AM, Gonzalo BG via Boost wrote:
> FWIW I needed a small_flat_set (that I later switched to a static_set), so
> I went on to define a type alias for boost::flat_set just to discover that
> the container type is not customizable...
>
> So I just quickly reimplemented flat_set as a container adaptor, and now I
> have type aliases for small_flat_set and static_set for free.
>
> I've extracted my impl and put it in a gist on github, in case somebody
> runs into the same issue and wants a workaround, it depends on some
> internal assert macros and range-v3 for concept-checking, but it shouldn't
> be hard to workaround those and adapt it to your needs:
>
> https://gist.github.com/gnzlbg/3949636aee663927d1cb338f00ce6733
>
> It's "good enough for me" but is not perfect (e.g. no methods with a
> position hint, one can certainly optimize the range inserts further, its
> not stable, and it does not model AssociativeContainer because it doesn't
> provide a value_type).

Shouldn't leveraging the EBO for Compare should probably only happen
conditionally: i.e. when !std::is_final_v<Compare> is true?

On the other hand, maybe your small_flat_set could also be achieved
with boost::container::flat_set with a custom allocator (instead of
the default allocator).

Glen


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