Imagine that I have a class whose main responsibility is to populate a data container. I would like to move the data out of this class. So I have:
class cCreator
{
public:
void generate()
{
///generate the content of data_ and populate it
....
....
}
//variation 1
std::vector<int>&& getData1()
{
return std::move(data_);
}
//variation 2
std::vector<int> getData2()
{
return std::move(data_);
}
private:
std::vector<int> data_
};
S what is the difference between variation 1 and variation 2 of getData(). What changes when I omit && from the function definition??