I am not exactly sure about this, so please explain me how does it work.
Let's consider following code.
std::vector<std::string> vec {};
void add (std::vector<std::string>&& v) {
using iter = std::vector<std::string>::iterator;
vec.insert (vec.end (),
std::move_iterator<iter> (v.begin ()),
std::move_iterator<iter> (v.end ()));
}
Are all elements of v
going to be moved? std::vector<T>::insert()
for the range version requires first and last iterators, so having the code like this how can it know that v.begin()+1
has also to be moved? Is the implementation of std::vector<T>::insert()
distinguish between "normal" and "move" iterators?
Aucun commentaire:
Enregistrer un commentaire