If I have a type like this
std::vector<int> const value = ...
Which one is a better solution?
style 1 :
for(auto v : value){
//do something
}
style 2 :
for(auto &&v : value){
//do something
}
style 3 :
for(auto const v : value){
//do something
}
All of them keep the constness of the type.
Style 2 is the most generic solution.
According to what I know, for primitive type like int, double etc, pass by value is prefer over pass by const reference, so I think style 1 and style 3 is better than style 2 if we know the type of vector is primitive type. Please forgive me if this question sound stupid.