|
Boost : |
Subject: Re: [boost] [flat_set] When to sort?
From: Marc Glisse (marc.glisse_at_[hidden])
Date: 2017-04-08 07:34:24
On Sat, 8 Apr 2017, Ion Gaztañaga via Boost wrote:
> On 29/03/2017 4:13, Chris Glover via Boost wrote:
>> We can have different "adopt" variants depending on the guarantees the
>> user provides, just like we have different "insert" versions
>> (ordered_unique_t, etc.). The "safe" one can assume passed vector is
>> unordered and just sorts and calls unique if needed. Other variants
>> might just skip sorting if the user requires so.
>>
>>
>> Sure.
>
> Committed to develop new experimental functions:
>
> class flat_map/set
> {
> sequence_type extract_sequence();
> void adopt_sequence(sequence_type &&seq);
> void adopt_sequence(ordered_unique_range_t, sequence_type &&seq);
> };
>
> class flat_multimap/multiset
> {
> sequence_type extract_sequence();
> void adopt_sequence(sequence_type &&seq);
> void adopt_sequence(ordered_range_t, sequence_type &&seq);
> };
>
> Let's see if they are useful. Any feedback welcome.
That seems more complicated than simply giving (in-place) access to the
internal sequence_type. You already had to document the invariants for
adopt_sequence(ordered_unique_range_t,*) and more or less promised that
extract_sequence takes constant time, so the abstraction doesn't buy you
much.
-- Marc Glisse
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk