Inconsistencies with associative/unordered containers
Jonathan Wakely
jwakely@redhat.com
Tue Jul 7 22:49:16 GMT 2020
On 03/07/20 08:37 +0200, François Dumont via Libstdc++ wrote:
>Hi
>
>Â Â Â Here is the patch to fix the 2nd point of this mail below.
>
>Â Â Â I prefer to qualify _Rb_tree_impl move constructor based on
>std::is_nothrow_move_constructible<_Base_key_compare> so that the
>logic of copying _Compare rather than moving it stays an
>implementation detail of _Rb_tree_key_compare.
>
>Â Â Â libstdc++: Fix [multi]map/[multi]set move constructors noexcept
>qualification
>
>Â Â Â Container move constructors shall not consider their allocator move
>Â Â Â constructor qualification.
>
>Â Â Â libstdc++-v3/ChangeLog:
>
>Â Â Â Â Â Â Â Â Â Â Â * include/bits/stl_tree.h
>(_Rb_tree_impl(_Rb_tree_impl&&)): Add noexcept
>Â Â Â Â Â Â Â Â Â Â Â qualification based only on _Compare one.
>Â Â Â Â Â Â Â Â Â Â Â *
>testsuite/23_containers/map/cons/noexcept_move_construct.cc: Add
>Â Â Â Â Â Â Â Â Â Â Â static asserts.
>Â Â Â Â Â Â Â Â Â Â Â *
>testsuite/23_containers/multimap/cons/noexcept_move_construct.cc:
>Â Â Â Â Â Â Â Â Â Â Â Likewise.
>Â Â Â Â Â Â Â Â Â Â Â *
>testsuite/23_containers/multiset/cons/noexcept_move_construct.cc:
>Â Â Â Â Â Â Â Â Â Â Â Likewise.
>Â Â Â Â Â Â Â Â Â Â Â *
>testsuite/23_containers/set/cons/noexcept_move_construct.cc: Likewise.
>
>New tests run under Linux x86_64, ok to commit after other tests complete ?
[...]
>diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h
>index 39303c47b08..d7f5439f452 100644
>--- a/libstdc++-v3/include/bits/stl_tree.h
>+++ b/libstdc++-v3/include/bits/stl_tree.h
>@@ -706,7 +706,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> : _Node_allocator(__a), _Base_key_compare(__comp)
> { }
> #else
>- _Rb_tree_impl(_Rb_tree_impl&&) = default;
>+ _Rb_tree_impl(_Rb_tree_impl&&)
>+ noexcept(
>+ std::is_nothrow_move_constructible<_Base_key_compare>::value )
>+ = default;
If you remove the redundant "std::" this will fit on one line.
OK for master with that change, thanks.
I need to check which branches will allow the noexcept-specifier on a
defaulted constructor. I don't think we can backport it to all
branches.
More information about the Libstdc++
mailing list