#include <bits/stdc++.h>
int main () {
std::string foo = "string_1";
std::string bar = "string_2";
std::vector<std::string> myvector;
myvector.push_back (foo);
myvector.push_back (std::move(bar));
for (std::string x:myvector)
std::cout << x << '\n' ;
}
How's that code is diffrent when I exchange
for (std::string x:myvector)
for?
for (std::string& x:myvector)
I'm guessing there are a lot of places when I could find that, but I don't know what's the name of this measure, so I don't know what I should search for. Link to explanation will be enough if it's it's easier for you.
EDIT:
What's the diffrence between:
for(auto x:my_vector)
for(auto& x:my_vector)
for(auto&& x:my_vector)