#include <vector>
#include <string>
#include <iostream>
struct Data
{
std::vector<std::string> m_datas;
Data() {}
Data(Data&)
{
std::cout << "cp constructor" << std::endl;
}
};
void GetData2(Data&& data)
{
std::cout << "forward" << std::endl;
std::cout << data.m_datas.size() << std::endl;
}
void Get(Data&& data)
{
std::cout << "move" << std::endl;
std::cout << data.m_datas.size() << std::endl;
GetData2(std::forward<Data&&>(data));
}
void GetCopy(Data data)
{
std::cout << "get data" << std::endl;
std::cout << data.m_datas.size() << std::endl;
}
int main()
{
Data d;
for (int i = 0; i < 100; i++)
{
d.m_datas.emplace_back(std::string(100000, 'a'));
}
Get(std::move(d));
GetCopy(d);
return 0;
}