Just forget about this patch, bad idea.

The key_type might have additional data not used for the comparison. This data would not be preserved if we were inserting the already stored equivalent key instead of the user provided.


On 22/02/23 07:08, François Dumont wrote:
This one is a refinement for multimap/multiset.

It allows to have share the same key if managed with ref counting like the cow string.

    libstdc++: [_Rb_tree] Limit allocations on equal insertions [PR 96088]

    When inserting the same key several times prefer to insert the new entry using the     current stored key_type instance if this copy is noexcept. Otherwise create a new
    key instance from input argument.

    libstdc++-v3/ChangeLog:

            PR libstdc++/96088
            * include/bits/cow_string.h (basic_string<>::basic_string(const basic_string&)):
            Add noexcept qualification when allocator is always equal.
            * include/bits/stl_tree.h (_Rb_tree<>::_M_get_insert_equal_pos_tr): New.
            (_Rb_tree<>::_M_emplace_equal_tr): New, use latter.
            (_Rb_tree<>::_M_emplace_equal_aux): New, use latter.
(_Rb_tree<>::_M_emplace_equal<_Arg>(_Arg&&)): New, use latter.
            * testsuite/23_containers/multimap/96088.cc (test01): Add check on redundant
            insertion.
            (test02): Likewise.
            * testsuite/23_containers/multiset/96088.cc (test01, test02): Likewise.

François


Reply via email to