In certain cases vector can use memcpy to construct a range of elements at the back of the vector. We currently don't do this resulting in terrible code gen in non-optimized mode and a
very large slowdown compared to libstdc++.
This patch adds a __construct_forward_range(Allocator, Iter, Iter, _Ptr&) and __construct_forward_range(Allocator, Tp*, Tp*, Tp*&) functions to allocator_traits which act similarly to the existing __construct_forward(...) functions.
This patch also changes vectors __construct_at_end(Iter, Iter) to be __construct_at_end(Iter, Iter, SizeType) where SizeType is the size of the range. __construct_at_end(Iter, Iter, SizeType) now calls allocator_traits<Tp>::__construct_forward_range(...).
This patch is based off the design of __swap_out_circular_buffer(...) which uses allocator_traits<Tp>::__construct_forward(...).
On my machine this code performs 4x better than the current implementation when tested against std::vector<int>.