class Whatever
{
public:
virtual ~Whatever();
protected:
Whatever();
virtual void SomeMethod();
void OnEventOccurred(int x);
std::vector<boost::signals2::scoped_connection> boostSignalConnections_;
}
//.cpp
Whatever::SomeMethod()
{
...
boostSignalConnections_.push_back(
anObject->AddEventOccurredObserver(
std::bind(&Whatever::OnEventOccurred,
this, std::placeholders::_1)));
...
}
(Note AddEventOccurredObserverjust delegates boost::signals2::connect()and returns boost::signals2::connection)
I get the following error. It's hard to interpret template errors, but it seems like an error occurs when declaring a memberstd::vector<boost::signals2::scoped_connection> boostSignalConnections_;
...\vc\include\xmemory(202): error C2248:
'boost::signals2::scoped_connection::scoped_connection' :
cannot access private member declared in class 'boost::signals2::scoped_connection'
...\boost_1_47\boost\signals2\connection.hpp(234) : see declaration of
'boost::signals2::scoped_connection::scoped_connection'
...\boost_1_47\boost\signals2\connection.hpp(210) :
see declaration of 'boost::signals2::scoped_connection'
...\vc\include\xmemory(201) : while compiling class template member function
'void std::allocator<_Ty>::construct(boost::signals2::scoped_connection *,_Ty &&)'
with
[
_Ty=boost::signals2::scoped_connection
]
I searched, and I think this could be due to the fact that scoped_connection is not being copied? I'm not sure. The reason I use scoped_connection is related to this SO question:
Handle the connection / disconnection of many signals / slots with boost :: signals2
Update
FYI, scoped_connection connection, : std::vector<boost::signals2::connection> boostSignalConnections_;. scoped_connection , , , connection . .