[PATCH] Optimize inserting value_type into std::vector
Jonathan Wakely
jwakely@redhat.com
Mon Jun 20 06:52:00 GMT 2016
On 18/06/16 10:41 +0800, Yubin Ruan wrote:
>my question is in regard to the two lines below
>
>> *end() = std::move(*it);
>> ++this->_M_impl._M_finish;
>
>Isn't it illegal to dereference `end()` ?
It was just pseudocode really (the code I gave doesn't work with
allocators that use non-builtin pointers). The first line above
should be:
allocator_traits<allocator_type>::construct(get_allocator(),
data()+size(),
std::move(*it));
>what does `++this->_M_impl._M_finish` do here ?
It updates the size of the vector, to include the new element
constructed at the end.
>Any libstdc++ specified stuff here ?
Obviously _M_impl._M_finish is specific to our implementation, but
others will have something similar with different names.
More information about the Libstdc++
mailing list