Consider the following code:
#include <iostream>
#include<vector>
#include<unordered_map>
class Domain {
public:
enum class fieldname {
pos_x, pos_y
};
std::unordered_map<fieldname, std::vector<double>> data;
};
int main()
{
Domain d;
std::vector<double> f = {1, 3, 4, 5};
d.data[Domain::fieldname::pos_x] = f;
// if f is large?
// d.data[Domain::fieldname::pos_x] = std::move(f);
// use d for other stuff
// ...
return 0;
}
I have assigned f to the map member using a copy. I would like to find out if using std::move like in the commented line below it will be different in terms of a) memory usage b) runtime when f is a large vector (say 10% RAM). Thank you.