Boost logo

Boost Users :

From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2004-07-24 02:16:49


I want to use boost::shared_ptr with boost::signal.

class A
        int     _i;
        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.
Maybe I can use a proxy class which aggregates the smart pointer but maybe
there is a better solution?!

with best regards,

"Der Spezialist ist ein Barbar, dessen Unwissenheit nicht allumfassend ist."
Master's Voice, S.LEM

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at