Boost logo

Boost Users :

From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2004-07-25 11:32:54


Am Samstag, 24. Juli 2004 22:22 schrieb Edward Diener:

> 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" ?

In your suggestion the instance of A where the smart pointer points to has the
value _i == 0 (copies were created)!
I want a value of 3!

boost::signal< void( int, std::string) > rsig;
boost::signal< void( std::string, int) > lsig;
boost::shared_ptr< A > aptr( new A() );
rsig.connect( *aptr);
lsig.connect( *aptr);
rsig(0,"called from right side");
lsig("called from left side",0);
std::cout << aptr->get() << std::endl; // should print 3, but aptr has value 0

A proxy (with operator()(int, string) and operator(string,0)) which contains
the smart pointer aptr could be connected to signal but maybe there is a
better solution?!

thx,
Oliver

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

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