Commit 0ae207e9 by Jonathan Wakely Committed by Jonathan Wakely

Optimize inserting value_type into std::vector

	* include/bits/stl_vector.h (vector::_S_insert_aux_assign): Define
	new overloaded functions.
	* include/bits/vector.tcc (vector::_M_insert_aux): Use new functions
	to avoid creating a redundant temporary.
	* testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc: New
	test.

From-SVN: r237526
parent f5e336b1
2016-06-16 Jonathan Wakely <jwakely@redhat.com>
* include/bits/stl_vector.h (vector::_S_insert_aux_assign): Define
new overloaded functions.
* include/bits/vector.tcc (vector::_M_insert_aux): Use new functions
to avoid creating a redundant temporary.
* testsuite/23_containers/vector/modifiers/insert_vs_emplace.cc: New
test.
2016-06-15 François Dumont <fdumont@gcc.gnu.org>
* include/bits/stl_deque.h
......
......@@ -1412,6 +1412,15 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_M_insert_aux(iterator __position, const value_type& __x);
#else
template<typename... _Args>
static void
_S_insert_aux_assign(iterator __pos, _Args&&... __args)
{ *__pos = _Tp(std::forward<_Args>(__args)...); }
static void
_S_insert_aux_assign(iterator __pos, _Tp&& __arg)
{ *__pos = std::move(__arg); }
template<typename... _Args>
void
_M_insert_aux(iterator __position, _Args&&... __args);
......
......@@ -343,7 +343,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus < 201103L
*__position = __x_copy;
#else
*__position = _Tp(std::forward<_Args>(__args)...);
_S_insert_aux_assign(__position, std::forward<_Args>(__args)...);
#endif
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment