C++98 containers defined two kinds of iterator, ::iterators and ::const_iterators. Generally, like this:
class Vector{
iterator begin();
const_iterator begin() const;
};
In C++11 this part of the design seems to be unchanged. The question is, for consistency and for practical purposes would it make sense to add ::move_iterators as well? or it an overkill.
I can imagine that an rvalue container maybe have their elements moved if possible.
class Vector{
iterator begin() &;
const_iterator begin() const&;
move_iterator begin() &&;
};
If I understand correctly, it could be implemented like this in simple cases:
auto Vector::begin() &&{return std::make_move_iterator(this->begin());}
Aucun commentaire:
Enregistrer un commentaire