If I pass a container by constant reference, is there a point in declaring a constant reference in a range-for loop, or will the elements in the loop automatically inherent that property?
i.e.
int foo(std::vector<int> const& vec) {
for (int const& el : vec)
// do something...
}
is the above equivalent to:
int foo(std::vector<int> const& vec) {
for (int el : vec)
// do something...
}
Aucun commentaire:
Enregistrer un commentaire