diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2018-10-25 15:03:13 +0200 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2018-10-25 13:03:13 +0000 |
commit | 0f317ef76269a989ae751a808f946d15b740baf9 (patch) | |
tree | 9da28f80357d64a8e89cdd7f85a670e3161265a4 /libstdc++-v3/include/bits/alloc_traits.h | |
parent | 09d3f04eaea862476be3c74fd84f06ec1afb1e68 (diff) | |
download | gcc-0f317ef76269a989ae751a808f946d15b740baf9.tar.gz |
Relocation (= move+destroy)
2018-10-25 Marc Glisse <marc.glisse@inria.fr>
PR libstdc++/87106
* include/bits/alloc_traits.h (_S_construct, _S_destroy, construct,
destroy): Add noexcept specification.
* include/bits/allocator.h (construct, destroy): Likewise.
* include/ext/alloc_traits.h (construct, destroy): Likewise.
* include/ext/malloc_allocator.h (construct, destroy): Likewise.
* include/ext/new_allocator.h (construct, destroy): Likewise.
* include/bits/stl_uninitialized.h (__relocate_object_a, __relocate_a,
__relocate_a_1): New functions.
(__is_trivially_relocatable): New class.
* include/bits/stl_vector.h (__use_relocate): New static member.
* include/bits/vector.tcc (reserve, _M_realloc_insert,
_M_default_append): Use __relocate_a.
(reserve, _M_assign_aux, _M_realloc_insert, _M_fill_insert,
_M_default_append, _M_range_insert): Move _GLIBCXX_ASAN_ANNOTATE_REINIT
after _Destroy.
* testsuite/23_containers/vector/modifiers/push_back/49836.cc:
Replace CopyConsOnlyType with DelAnyAssign.
From-SVN: r265485
Diffstat (limited to 'libstdc++-v3/include/bits/alloc_traits.h')
-rw-r--r-- | libstdc++-v3/include/bits/alloc_traits.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h index 742fdd0447d..9321fdff352 100644 --- a/libstdc++-v3/include/bits/alloc_traits.h +++ b/libstdc++-v3/include/bits/alloc_traits.h @@ -240,6 +240,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp, typename... _Args> static _Require<__has_construct<_Tp, _Args...>> _S_construct(_Alloc& __a, _Tp* __p, _Args&&... __args) + noexcept(noexcept(__a.construct(__p, std::forward<_Args>(__args)...))) { __a.construct(__p, std::forward<_Args>(__args)...); } template<typename _Tp, typename... _Args> @@ -247,17 +248,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Require<__and_<__not_<__has_construct<_Tp, _Args...>>, is_constructible<_Tp, _Args...>>> _S_construct(_Alloc&, _Tp* __p, _Args&&... __args) + noexcept(noexcept(::new((void*)__p) + _Tp(std::forward<_Args>(__args)...))) { ::new((void*)__p) _Tp(std::forward<_Args>(__args)...); } template<typename _Alloc2, typename _Tp> static auto _S_destroy(_Alloc2& __a, _Tp* __p, int) + noexcept(noexcept(__a.destroy(__p))) -> decltype(__a.destroy(__p)) { __a.destroy(__p); } template<typename _Alloc2, typename _Tp> static void _S_destroy(_Alloc2&, _Tp* __p, ...) + noexcept(noexcept(__p->~_Tp())) { __p->~_Tp(); } template<typename _Alloc2> @@ -340,6 +345,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template<typename _Tp, typename... _Args> static auto construct(_Alloc& __a, _Tp* __p, _Args&&... __args) + noexcept(noexcept(_S_construct(__a, __p, + std::forward<_Args>(__args)...))) -> decltype(_S_construct(__a, __p, std::forward<_Args>(__args)...)) { _S_construct(__a, __p, std::forward<_Args>(__args)...); } @@ -353,6 +360,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template<typename _Tp> static void destroy(_Alloc& __a, _Tp* __p) + noexcept(noexcept(_S_destroy(__a, __p, 0))) { _S_destroy(__a, __p, 0); } /** @@ -472,6 +480,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Up, typename... _Args> static void construct(allocator_type& __a, _Up* __p, _Args&&... __args) + noexcept(noexcept(__a.construct(__p, std::forward<_Args>(__args)...))) { __a.construct(__p, std::forward<_Args>(__args)...); } /** @@ -484,6 +493,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Up> static void destroy(allocator_type& __a, _Up* __p) + noexcept(noexcept(__a.destroy(__p))) { __a.destroy(__p); } /** |