Subject: Re: [boost] [container] moving a pre-built vector into a flat_set
From: Gonzalo BG (gonzalobg88_at_[hidden])
Date: 2017-03-12 11:22:57
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:
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).
On Thu, Sep 17, 2015 at 2:07 PM, Seth <bugs_at_[hidden]> wrote:
> It strikes me that more containers could enjoy this mechanism.
> Perhaps we need a concept for "MovableContiguousContainer" and
> "MovableContiguousStorage". Perhaps with sub concepts for the aligned
> versions too.
> Because I can totally see `basic_string<T>::basic_string(vector<T>&&)`
> and `std::vector<T>::vector(basic_string<T>&&)` being helpful just the
> So, if we think about this beyond the scope of flat_* then we might
> actually create something that could be proposed for future c++.
> Thinking of `flat_set<T>::flat_set(MovableContiguousStorage<T>&&)`Â¹
> Â¹ (I don't know concepts syntax)
> On Tue, Sep 15, 2015, at 11:03 PM, Sam Kellett wrote:
> > a common problem i encounter is that i have two stage's w/r/t to a large
> > collection of data: building and querying.
> > vector is obviously the king of building. flat_set is the king of
> > querying.
> > so what i often tend to do is build up a very large vector, sort it then
> > create a flat_set using the flat_set(ordered_unique_t) constructor.
> > however this still copies the entire vector into the flat_set, right?
> > what i would like to be able to do is move the vector straight into the
> > flat_set, something like:
> > std::vector<T> data;
> > flat_set data_set1(std::move(data)) // move vector in and sort it
> > // or:
> > std::sort(data.begin(), data.end()); // sort vector
> > flat_set data_set2(ordered_unique_t, std::move(data)) // and move it in
> > is this doable (am i just being blind?) or is there plans/interest for
> > this?
> > _______________________________________________
> > Unsubscribe & other changes:
> > http://lists.boost.org/mailman/listinfo.cgi/boost
> Unsubscribe & other changes: http://lists.boost.org/mailman