
Untitled
By: a guest on
May 9th, 2012 | syntax:
None | size: 0.72 KB | hits: 18 | expires: Never
C - Boost.Promise, Boost.Unique_Future and Move Semantics
#include <iostream>
#include <cassert>
#include <boostthread.hpp>
#include <boostthreadfuture.hpp>
void thFun(boost::promise<std::string> & prms)
{
std::string str("Hi from future!");
prms.set_value(str);
}
int main()
{
boost::promise<std::string> prms;
boost::unique_future<std::string> fut = prms.get_future();
boost::thread th(&thFun, std::move(prms)); // error C2248: 'boost::promise<R>::promise' : cannot access private member declared in class 'boost::promise<R>'
std::cout << "Hi from main!";
std::string str = fut.get();
std::cout << str << std::endl;
th.join();
return 0;
}
boost::thread th(&thFun, std::move(prms));