emplace_back must return reference to back(), not to *end()

This commit is contained in:
Tobias Reh
2017-02-24 15:33:30 +01:00
parent ce5996c9bd
commit 5fe2dba504

View File

@@ -1735,9 +1735,10 @@ class vector
{ {
if (BOOST_LIKELY(this->room_enough())){ if (BOOST_LIKELY(this->room_enough())){
//There is more memory, just construct a new object at the end //There is more memory, just construct a new object at the end
allocator_traits_type::construct(this->m_holder.alloc(), this->priv_raw_end(), ::boost::forward<Args>(args)...); T* const p = this->priv_raw_end();
allocator_traits_type::construct(this->m_holder.alloc(), p, ::boost::forward<Args>(args)...);
++this->m_holder.m_size; ++this->m_holder.m_size;
return *this->priv_raw_end(); return *p;
} }
else{ else{
typedef container_detail::insert_emplace_proxy<Allocator, T*, Args...> type; typedef container_detail::insert_emplace_proxy<Allocator, T*, Args...> type;