Change emplace for vector and deque to create the temporary (when necessary) before any changes to the container are made. Nikolay Ivchenkov deserves the credit for pushing this problem and the solution for it.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@159918 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1681,8 +1681,9 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
|
||||
}
|
||||
else
|
||||
{
|
||||
value_type __tmp(_VSTD::forward<_Args>(__args)...);
|
||||
__move_range(__p, this->__end_, __p + 1);
|
||||
*__p = value_type(_VSTD::forward<_Args>(__args)...);
|
||||
*__p = _VSTD::move(__tmp);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user