This question already has an answer here:
I'm using C++11, why is the first case working while the second needs auto&& ?
#include <vector>
#include <iostream>
struct Obj {
};
int main()
{
std::vector<Obj> vobj(10);
for (auto& e : vobj) // Works
std::cout << "Yes";
std::vector<bool> v(10, false);
for (auto& e : v) // Fails
e = true;
}
Aucun commentaire:
Enregistrer un commentaire