Fix std::vector's use of temporary objects
commitc1e8e16c5c977ebc08d3a76e5ae9428b693d8a8c
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 4 Jul 2016 14:52:46 +0000 (4 14:52 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 4 Jul 2016 14:52:46 +0000 (4 14:52 +0000)
tree4b2a3c27c66a41421f137be57c5d0b026e557dea
parent2da1c9f7c3edcdda292b767bf340a85161101332
Fix std::vector's use of temporary objects

* include/bits/stl_vector.h (emplace(const_iterator, _Args&&...)):
Define inline. Forward to _M_emplace_aux.
(insert(const_iterator, value_type&&)): Forward to _M_insert_rval.
(_M_insert_rval, _M_emplace_aux): Declare new functions.
(_Temporary_value): New RAII type using allocator to construct/destroy.
(_S_insert_aux_assign): Remove.
(_M_insert_aux): Make non-variadic.
* include/bits/vector.tcc (insert(const_iterator, const value_type&)):
Use _Temporary_value.
(emplace(const_iterator, _Args&&...)): Remove definition.
(_M_insert_rval, _M_emplace_aux): Define.
(_M_insert_aux): Make non-variadic, stop using _S_insert_aux_assign.
(_M_fill_insert): Use _Temporary_value.
* testsuite/23_containers/vector/allocator/construction.cc: New test.
* testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc:
Adjust expected results for emplacing an lvalue with reallocation.
* testsuite/23_containers/vector/check_construct_destroy.cc: Adjust
expected results to account for construction/destruction of temporary
using allocator.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237985 138bc75d-0d04-0410-961f-82ee72b054a4
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_vector.h
libstdc++-v3/include/bits/vector.tcc
libstdc++-v3/testsuite/23_containers/vector/allocator/construction.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/vector/check_construct_destroy.cc
libstdc++-v3/testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc
libstdc++-v3/testsuite/backward/hash_set/check_construct_destroy.cc