Có mã như sau:Trộn std :: move() và std :: chủ đề sẽ không biên dịch
#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 (bộ công cụ V110) cho lỗi tiếp theo:
error C2664: '_Rx std::_Pmf_wrap<_Pmf_t,_Rx,_Farg0,_V0_t,_V1_t,_V2_t,_V3_t,_V4_t,_V5_t,>::operator()(const _Wrapper &,_V0_t) const' : cannot convert parameter 2 from 'int' to 'int &&'
Cái gì thế? Chúng ta không thể sử dụng ngữ nghĩa di chuyển qua các chủ đề?
Đối với những gì nó có giá trị, điều này không biên dịch trong g ++ và clang. – user2079303