|
Boost Users : |
Subject: [Boost-users] [Thread] Constructing a move-only object asyncronously
From: Alexander Lamaison (awl03_at_[hidden])
Date: 2013-03-19 14:40:17
I'm trying to create a move-only object asyncronously using Boost.Thread
unique_future but I'm running into trouble:
error C2248: 'A::A' : cannot access private member declared in class 'A'
c:\users\awl03\documents\visual studio
2005\projects\boost_1_51_0\boost\thread\future.hpp 493
I've tried all sorts of ways to work around this but always end up with
some variation or other of this error message. What am I doing wrong?
The code is below. The setup is:
Visual Studio 2005
Boost 1.51
Thanks,
Alex
#include <boost/noncopyable.hpp>
#include <boost/move/move.hpp>
#include <boost/thread/future.hpp>
#include <boost/thread/thread.hpp>
using namespace boost;
class A : public noncopyable
{
BOOST_MOVABLE_BUT_NOT_COPYABLE(A)
public:
A(int i) {}
A(BOOST_RV_REF(A) other) {}
A& operator=(BOOST_RV_REF(A) other) {}
};
A create_a()
{
return A(42);
}
unique_future<A> async_create_a()
{
packaged_task<A> task(create_a);
unique_future<A> result = task.get_future();
thread(move(task)).detach();
return move(result);
}
int main()
{
A a = async_create_a().get();
return 0;
}
-- Swish - Easy SFTP for Windows Explorer (http://www.swish-sftp.org)
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net