
Gottlob Frege wrote:
On 2/23/07, Frank Mori Hess
wrote: Could you give a short example of how that would look with using bind and a simple free function expecting a pointer or reference to an object that should be tracked?
Attached.
From the attached: boost::shared_ptr<coordinate> coord(new coordinate); coord->x = 5; sig.connect(boost::bind(&myfunction, boost::signalslib::track(coord, boost::ref(coord->x))));
I actually like the suggestion of just offering a way to add the tracked pointers manually. Either sig.connect( boost::bind( myfunction, boost::ref(coord->x) ), coord ); or sig.connect( boost::bind( myfunction, boost::ref(coord->x) ).track( coord ); Both look better on a syntactic level to me. In addition, I suspect that signalslib::track contains a race condition that is avoided by the other alternatives (but I haven't actually looked at it so I might be wrong; it's possible, if somewhat tedious, to implement it correctly).