Boost logo

Boost :

Subject: Re: [boost] [container] moving a pre-built vector into a flat_set
From: Sam Kellett (samkellett_at_[hidden])
Date: 2015-09-16 11:10:25


>
> > Well, almost.
> >
> > IMO, we need three things to make it perfect:
> >
> > A. flat_set/map should have an additional template argument specifying
> the
> > internal vector type (it can default to the current choice).
> >
> > B. You should be able to move the whole container, as suggested.
> >
> > C. The constructor should contain an assertion with a call to is_sorted()
>
> So essentially, flat_set/map would now be an adapter like a stack or queue.
> Makes sense. About C, I rather think that we should have two constructors:
>
> flat_set/map(storage raw)
> flat_set/map(ordered_unique_range_t, storage sorted)
>

+1

> and then the is_sorted() assert check should be done in the second
> constructor, and the first one would call sort().
>

i'd be scared that this check will nullify a lot of the benefit of this new
constructor. as the is_sorted assertion i assume would have to go through
the data to verify this which brings this constructor down to the same O(n)
complexity as it's iterator pair counterpart.

does the flat_set(ordered_unique_t, first, last) constructor do the
is_sorted check? or is it undefined behaviour if the input data is out of
order? i guess it does seeing as how it has to loop through the data anyway
it might as well..

i would err on the side of this new constructor simply being undefined
behaviour if non-sorted data is given to it


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