кусок и мувает туда все элементы, так вот, получается для всех элементов вызывается move-конструктор? или он как-то через memcpy/memmove все это делает?
посмотри
как минимум меммув и мемспу нельзя юзать для nontrivial copyble типов
23.3.6.2 vector capacity [vector capacity] void reserve(size_type n); 2 Effects: A directive that informs a vector of a planned change in size, so that it can manage the storage allocation accordingly. After reserve(), capacity() is greater or equal to the argument of reserve if reallocation happens; and equal to the previous value of capacity() otherwise. Reallocation happens at this point if and only if the current capacity is less than the argument of reserve(). If an exception is thrown other than by the move constructor of a non-CopyConstructible type, there are no effects. 23.3.6.4 vector modifiers [vector.modifiers] Remarks: Causes reallocation if the new size is greater than the old capacity. If no reallocation happens, all the iterators and references before the insertion point remain valid. If an exception is thrown other than by the copy constructor, move constructor, assignment operator, or move assignment operator of T or by any InputIterator operation there are no effects. If an exception is thrown by the move constructor of a non-CopyConstructible T, the effects are unspecified.
Вызывает конструктор, какой именно зависит от noexcept move
memmove может вызваться, если хранимый тип TriviallyCopyable. А так, там для всех вызывается std::move_if_noexcept
Либо move либо copy
Обсуждают сегодня