I run into problem with rvalue references in MSVC 2012.
#include <thread>
#include <string>
#include <future>
void foo(std::promise<std::string> &&prms) { /* some code */ }
int main() {
std::promise<std::string> prms;
// std::future<std::string> ftr = prms.get_future();
std::thread th(&foo, std::move(prms));
// some other code
}
Compiler says: error C2664: ‘void (std::promise<_Ty> &&)’ : cannot convert parameter 1 from ‘std::promise<_Ty>’ to ‘std::promise<_Ty> &&’
Is there my mistake (then how to fix it) or compiler issue (then I’d like to know origin of such behaviour)?
This is a known issue in the Visual C++ 2012 implementation of
std::thread. See the following bug on Microsoft Connect:The response to that bug states: