On Sat, 8 Apr 2017, Ion GaztaƱaga via Boost wrote:
On 08/04/2017 9:34, Marc Glisse via Boost wrote:
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.
adopt/extract maintain class invariants which can avoid a lot of headaches. Even adopt_sequence(ordered[_unique[_range_t, ...) checks preconditions (ordered [and unique]) in debug mode.
The usual safety vs power. I tend to consider that debug mode should not influence design (much), but I understand your wish to maintain invariants and isolate the points where "unsafe" operations can be performed, and in this case the cost (2 vector moves) is not so bad.
Could you please elaborate what does "giving access to the internal sequence_type" mean? Something like:
class flat_xxx { sequence_type &sequence_ref() { return m_seq; } };
?
Yes. -- Marc Glisse