Fix std::vector's use of temporary objects
authorJonathan Wakely <jwakely@redhat.com>
Mon, 4 Jul 2016 14:52:46 +0000 (15:52 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 4 Jul 2016 14:52:46 +0000 (15:52 +0100)
commit9958c7eb586f40860546007fe0dc27165275c80d
tree4b2a3c27c66a41421f137be57c5d0b026e557dea
parentbf7499197fbb065123257c374064f6bb715c951b
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.

From-SVN: r237985
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