【发布时间】:2011-07-28 15:26:41
【问题描述】:
#include <type_traits>
template<class T>
typename std::remove_reference<T>::type&& move(T&& v)
{
return v;
}
void main()
{
int a;
move(a);
}
为什么这段代码不能编译?
错误 C2440:'return':无法将 'int' 转换为 'int &&'
【问题讨论】:
-
通过将
move应用于int究竟想达到什么目的? -
是的,我不知道。这只是一个例子。但也许我的例子是错误的。
标签: c++ visual-c++ c++11 rvalue-reference move-semantics