【发布时间】:2015-04-23 18:11:24
【问题描述】:
代码如下:
#include <memory>
#include <thread>
class A
{
void foo(int&& arg) const {}
void boo() const
{
int value(0);
std::thread t(&A::foo, this, std::move(value));
t.join();
}
};
int main()
{
A a;
return 0;
}
MS Visual Studio 2012 (toolset v110) 给出下一个错误:
错误 C2664:'_Rx std::_Pmf_wrap<_pmf_t>::operator ()(const _Wrapper &,_V0_t) const':无法转换参数 2 从'int'到'int &&'
那是什么?我们不能通过线程使用移动语义吗?
【问题讨论】:
-
不管怎样,这确实可以在 g++ 和 clang 中编译。