Oliver Kowalke wrote:
Hi,
I want to use boost::shared_ptr with boost::signal.
class A { private: int _i; public: A() : _i( 0) {}
void operator()( int, std::string & s) { i+= 1; }
void operator()( std::string & s, int) { i+= 2; } };
boost::shared_ptr< A > a( new A() ); boost::signal< void( int, std::string &) > rsig; boost::singal< void( std::string &, int) > lsig;
rsig.connect( a); lsig.connect( a);
rsig(0,"called from right side"); lsig("called from left side",0);
Because a is a smart_ptr this code would not compile because operator() is not a member function. If I dereference the smart pointer when I connect to signal, changes of a are never know by the other signal instance.
What's wrong with: rsig.connect(*a); lsig.connect(*a); When you now trigger rsig, a.operator()(int, std::string &s) is called. When you now trigger lsig, a.operator()(std::string &s,0) is called. What do you mean that "changes of 'a' are never know by the other signal instance" ?