0
我下一个片段从microsoft的std ::移动实现
template <typename T> struct RemoveReference {
typedef T type;
};
template <typename T> struct RemoveReference<T&> {
typedef T type;
};
template <typename T> struct RemoveReference<T&&> {
typedef T type;
};
template <typename T> typename RemoveReference<T>::type&& Move(T&& t) {
return t;
}
...
remote_integer x = frumple(5);
remote_integer&& x1 = Move(x);
,我得到一个错误“错误C2440: '回归':无法从 'remote_integer' 转换到'remote_integer & &''
在编译器中有所改变吗?随着std :: move一切顺利。
移动只接受一个右值,x是一个左值。你必须使用stdmove(小写)。 – RedX
http://social.msdn.microsoft.com/Forums/en-US/vs2010ctpcpp/thread/ab120b3c-4ecf-4a0d-8f64-f24925ac39a9/ - Jonathan Caves(Visual C++编译器团队)编写实现std :: move和我的Move一样。并移动我从微软网站抓住,在问题的链接?那里没有问题,但是在VC10中它不起作用。 – Yola
模板类型名称RemoveReference ::类型&&移动(T && T){ 回报(RemoveReference ::类型&&)t; } - 现在一切工作正常,一些与类型转换这里 –
Yola