diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2019-02-05 14:45:00 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2019-02-05 14:45:00 +0000 |
commit | 258bd1d63aec54899b12269325eca9712d61adfe (patch) | |
tree | 65711f6c5705ba57805df0b0ef11d57f6b05f11b /gcc/c | |
parent | 2781287255a16b6f2db18c68d02c3f40004332a7 (diff) | |
download | gcc-258bd1d63aec54899b12269325eca9712d61adfe.zip gcc-258bd1d63aec54899b12269325eca9712d61adfe.tar.gz gcc-258bd1d63aec54899b12269325eca9712d61adfe.tar.bz2 |
PR libstdc++/89130 restore support for non-MoveConstructible types
The changes to "relocate" std::vector elements can lead to new errors
outside the immediate context, because moving the elements to new
storage no longer makes use of the move-if-noexcept utilities. This
means that types with deleted moves no longer degenerate to copies, but
are just ill-formed. The errors happen while instantiating the
noexcept-specifier for __relocate_object_a, when deciding whether to try
to relocate.
This patch introduces indirections to avoid the ill-formed
instantiations of std::__relocate_object_a. In order to avoid using
if-constexpr prior to C++17 this is done by tag dispatching. After this
patch all uses of std::__relocate_a are guarded by checks that will
support sensible code (i.e. code not using custom allocators that fool
the new checks).
PR libstdc++/89130
* include/bits/alloc_traits.h (__is_copy_insertable_impl): Rename to
__is_alloc_insertable_impl. Replace single type member with two
members, one for each of copy and move insertable.
(__is_move_insertable): New trait for internal use.
* include/bits/stl_vector.h (vector::_S_nothrow_relocate(true_type))
(vector::_S_nothrow_relocate(true_type)): New functions to
conditionally check if __relocate_a can throw.
(vector::_S_use_relocate()): Dispatch to _S_nothrow_relocate based
on __is_move_insertable.
(vector::_S_do_relocate): New overloaded functions to conditionally
call __relocate_a.
(vector::_S_relocate): New function that dispatches to _S_do_relocate
based on _S_use_relocate.
* include/bits/vector.tcc (vector::reserve, vector::_M_realloc_insert)
(vector::_M_default_append): Call _S_relocate instead of __relocate_a.
* testsuite/23_containers/vector/modifiers/push_back/89130.cc: New.
From-SVN: r268537
Diffstat (limited to 'gcc/c')
0 files changed, 0 insertions, 0 deletions