#include <vector>
using namespace std;
struct TempData {
vector<int> data;
TempData() {
for(int i = 0; i < 100; i++) data.push_back(i);
}
// vector<int> GetData() { // function 1
// return move(data);
// }
vector<int>&& GetData() { // function 2
return move(data);
}
};
int main() {
vector<int> v;
{
TempData td;
v = td.GetData();
}
}
What is the difference between function 1 and function 2?
Will function 1 construct a temp vector with move(data) and then assign the temp vector to v?
No more details to add...