Il ne s'agit pas d'une garantie de la norme, mais d'un autre point de données, v.push_back(v[0])
est sans danger pour libc++ de LLVM .
de libc++ std::vector::push_back
appelle __push_back_slow_path
lorsqu'il doit réallouer de la mémoire :
void __push_back_slow_path(_Up& __x) {
allocator_type& __a = this->__alloc();
__split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1),
size(),
__a);
// Note that we construct a copy of __x before deallocating
// the existing storage or moving existing elements.
__alloc_traits::construct(__a,
_VSTD::__to_raw_pointer(__v.__end_),
_VSTD::forward<_Up>(__x));
__v.__end_++;
// Moving existing elements happens here:
__swap_out_circular_buffer(__v);
// When __v goes out of scope, __x will be invalid.
}