标签:perfect test 引用 右值引用 文件中 code c++ end https
<utility>
template<typename T>
void PrintT(T& t)
{
cout<<"lvaue"<<endl;
}
template<typename T>
void PrintT(T&& t)
{
cout<<"rvaue"<<endl;
}
template<typename T>
void TestForward(T&& v)
{
PrintT(v);
PrintT(std::forward<T>(v));
PrintT(std::move(v));
}
Test()
{
TestForward(1);
int x = 1;
TestForward(x);
TestForward(std::forward<int>(x));
}
标签:perfect test 引用 右值引用 文件中 code c++ end https
原文地址:https://www.cnblogs.com/fewolflion/p/12835754.html