dimanche 27 mars 2016

Auto reference and iterators

What happens if std::vector::begin() is called but the returned iterator is assigned to a reference? Why does it work and where is the iterator value stored?

std::vector<int> v;
auto a = v.begin(); //I assume iterator is stored on the stack in variable "a".
auto& b = v.begin(); //What happens here?

Aucun commentaire:

Enregistrer un commentaire