[Thread] Constructing a move-only object asyncronously
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
Le 19/03/13 19:40, Alexander Lamaison a écrit :
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
#include #include #include 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; }
Hi,
you need to use version 4 to got this functionality. I have modified
your example to use boost::future (*) and use packaged_task with a
signature parameter (**). With this change it to works for the following
toolsets.
bjam
toolset=darwin,darwin-4.6.2,darwin-4.7.1,clang-3.1,clang-3.2,darwin-latest,darwin-4.7.2
-l 300 variant=debug -j6
bjam
toolset=darwin,darwin-4.6.2,darwin-4.7.1,clang-3.1,clang-3.2,darwin-latest,darwin-4.7.2
-l 300 variant=debug -j6 ts_
iMac-de-Vicente-Botet-Escriba:test viboes$
Best,
Vicente
#define BOOST_THREAD_VERSION 4
#include
"Vicente J. Botet Escriba"
Le 19/03/13 19:40, Alexander Lamaison a écrit :
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?
snip
you need to use version 4 to got this functionality.
I assume this requires Boost 1.53?
I have modified your example to use boost::future (*) and use packaged_task with a signature parameter (**). With this change it to works for the following toolsets.
Thanks! Can you give me an idea of what changed in v4 to enable this?
I've looked through the history but nothing stands out.
I tried to make it work using just class thread rather than anything in
Le 19/03/13 20:30, Alexander Lamaison a écrit :
"Vicente J. Botet Escriba"
writes: Le 19/03/13 19:40, Alexander Lamaison a écrit :
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?
snip
you need to use version 4 to got this functionality. I assume this requires Boost 1.53?
I have modified your example to use boost::future (*) and use packaged_task with a signature parameter (**). With this change it to works for the following toolsets. Thanks! Can you give me an idea of what changed in v4 to enable this? I've looked through the history but nothing stands out.
I tried to make it work using just class thread rather than anything in
, but I couldn't work out how for a non-default constructible class.
I have just tried your example defining #define BOOST_THREAD_USES_MOVE and it works also. Vicente
"Vicente J. Botet Escriba"
Le 19/03/13 20:30, Alexander Lamaison a écrit :
"Vicente J. Botet Escriba"
writes: Le 19/03/13 19:40, Alexander Lamaison a écrit :
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?
snip
you need to use version 4 to got this functionality. I assume this requires Boost 1.53?
I have modified your example to use boost::future (*) and use packaged_task with a signature parameter (**). With this change it to works for the following toolsets. Thanks! Can you give me an idea of what changed in v4 to enable this? I've looked through the history but nothing stands out.
I tried to make it work using just class thread rather than anything in
, but I couldn't work out how for a non-default constructible class. I have just tried your example defining
#define BOOST_THREAD_USES_MOVE
and it works also.
Perfect. Thanks :) I'm assuming this solves the problem because the previous thread-internal move emulation didn't realise class A was movable and so tried to copy it. Is that right? Alex -- Swish - Easy SFTP for Windows Explorer (http://www.swish-sftp.org)
Le 20/03/13 00:22, Alexander Lamaison a écrit :
"Vicente J. Botet Escriba"
writes: Le 19/03/13 20:30, Alexander Lamaison a écrit :
"Vicente J. Botet Escriba"
writes: Le 19/03/13 19:40, Alexander Lamaison a écrit :
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?
snip
you need to use version 4 to got this functionality. I assume this requires Boost 1.53?
I have modified your example to use boost::future (*) and use packaged_task with a signature parameter (**). With this change it to works for the following toolsets. Thanks! Can you give me an idea of what changed in v4 to enable this? I've looked through the history but nothing stands out.
I tried to make it work using just class thread rather than anything in
, but I couldn't work out how for a non-default constructible class. I have just tried your example defining
#define BOOST_THREAD_USES_MOVE
and it works also. Perfect. Thanks :)
I'm assuming this solves the problem because the previous thread-internal move emulation didn't realise class A was movable and so tried to copy it. Is that right?
Yes, your code declared a move only class using the Boost.Move emulation. Boost.Thread has defined equivalent macros that use both emulations. Could you try with the following without defining BOOST_THREAD_USES_MOVE //#define BOOST_THREAD_USES_MOVE class A : public noncopyable { BOOST_THREAD_MOVABLE_ONLY(A) public: A(int ) {} A(BOOST_THREAD_RV_REF(A) ) {} A& operator=(BOOST_THREAD_RV_REF(A) ) { return *this;} }; Vicente
Le 20/03/13 13:26, Vicente J. Botet Escriba a écrit :
Le 20/03/13 00:22, Alexander Lamaison a écrit :
"Vicente J. Botet Escriba"
writes: Le 19/03/13 20:30, Alexander Lamaison a écrit :
"Vicente J. Botet Escriba"
writes: Le 19/03/13 19:40, Alexander Lamaison a écrit :
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?
snip
you need to use version 4 to got this functionality. I assume this requires Boost 1.53?
I have modified your example to use boost::future (*) and use packaged_task with a signature parameter (**). With this change it to works for the following toolsets. Thanks! Can you give me an idea of what changed in v4 to enable this? I've looked through the history but nothing stands out.
I tried to make it work using just class thread rather than anything in
, but I couldn't work out how for a non-default constructible class. I have just tried your example defining
#define BOOST_THREAD_USES_MOVE
and it works also. Perfect. Thanks :)
I'm assuming this solves the problem because the previous thread-internal move emulation didn't realise class A was movable and so tried to copy it. Is that right?
Yes, your code declared a move only class using the Boost.Move emulation. Boost.Thread has defined equivalent macros that use both emulations. Could you try with the following without defining BOOST_THREAD_USES_MOVE
//#define BOOST_THREAD_USES_MOVE
class A : public noncopyable { BOOST_THREAD_MOVABLE_ONLY(A)
public: A(int ) {}
A(BOOST_THREAD_RV_REF(A) ) {}
A& operator=(BOOST_THREAD_RV_REF(A) ) { return *this;}
};
Ah, you will need to add BOOST_THREAD_DCL_MOVABLE_BEG(T) A BOOST_THREAD_DCL_MOVABLE_END so that there is no conflict with Boost.Move. HTH, Vicente
"Vicente J. Botet Escriba"
Le 20/03/13 13:26, Vicente J. Botet Escriba a écrit :
Le 20/03/13 00:22, Alexander Lamaison a écrit :
"Vicente J. Botet Escriba"
writes: Le 19/03/13 20:30, Alexander Lamaison a écrit :
"Vicente J. Botet Escriba"
writes: Le 19/03/13 19:40, Alexander Lamaison a écrit : > 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? > snip
you need to use version 4 to got this functionality. I assume this requires Boost 1.53?
I have modified your example to use boost::future (*) and use packaged_task with a signature parameter (**). With this change it to works for the following toolsets. Thanks! Can you give me an idea of what changed in v4 to enable this? I've looked through the history but nothing stands out.
I tried to make it work using just class thread rather than anything in
, but I couldn't work out how for a non-default constructible class. I have just tried your example defining
#define BOOST_THREAD_USES_MOVE
and it works also. Perfect. Thanks :)
I'm assuming this solves the problem because the previous thread-internal move emulation didn't realise class A was movable and so tried to copy it. Is that right?
Yes, your code declared a move only class using the Boost.Move emulation. Boost.Thread has defined equivalent macros that use both emulations. Could you try with the following without defining BOOST_THREAD_USES_MOVE
//#define BOOST_THREAD_USES_MOVE
class A : public noncopyable { BOOST_THREAD_MOVABLE_ONLY(A)
public: A(int ) {}
A(BOOST_THREAD_RV_REF(A) ) {}
A& operator=(BOOST_THREAD_RV_REF(A) ) { return *this;}
};
Ah, you will need to add
BOOST_THREAD_DCL_MOVABLE_BEG(T) A BOOST_THREAD_DCL_MOVABLE_END
so that there is no conflict with Boost.Move.
This second version is working for me without those two defines. No conflicts occuring. Alex -- Swish - Easy SFTP for Windows Explorer (http://www.swish-sftp.org)
Le 20/03/13 18:56, Alexander Lamaison a écrit :
"Vicente J. Botet Escriba"
writes: Le 20/03/13 13:26, Vicente J. Botet Escriba a écrit :
Le 20/03/13 00:22, Alexander Lamaison a écrit :
"Vicente J. Botet Escriba"
writes: Le 19/03/13 20:30, Alexander Lamaison a écrit :
"Vicente J. Botet Escriba"
writes: > Le 19/03/13 19:40, Alexander Lamaison a écrit : >> 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? >> snip
> you need to use version 4 to got this functionality. I assume this requires Boost 1.53?
> I have modified your example to use boost::future (*) and use > packaged_task with a signature parameter (**). With this change it to > works for the following toolsets. Thanks! Can you give me an idea of what changed in v4 to enable this? I've looked through the history but nothing stands out.
I tried to make it work using just class thread rather than anything in
, but I couldn't work out how for a non-default constructible class. I have just tried your example defining
#define BOOST_THREAD_USES_MOVE
and it works also. Perfect. Thanks :)
I'm assuming this solves the problem because the previous thread-internal move emulation didn't realise class A was movable and so tried to copy it. Is that right?
Yes, your code declared a move only class using the Boost.Move emulation. Boost.Thread has defined equivalent macros that use both emulations. Could you try with the following without defining BOOST_THREAD_USES_MOVE
//#define BOOST_THREAD_USES_MOVE
class A : public noncopyable { BOOST_THREAD_MOVABLE_ONLY(A)
public: A(int ) {}
A(BOOST_THREAD_RV_REF(A) ) {}
A& operator=(BOOST_THREAD_RV_REF(A) ) { return *this;}
};
Ah, you will need to add
BOOST_THREAD_DCL_MOVABLE_BEG(T) A BOOST_THREAD_DCL_MOVABLE_END
so that there is no conflict with Boost.Move. This second version is working for me without those two defines. No conflicts occuring.
Great, glad so see that you have a solution now. Vicente
participants (2)
-
Alexander Lamaison
-
Vicente J. Botet Escriba