Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-02-23 12:22:06


Gottlob Frege wrote:
> On 2/23/07, Frank Mori Hess <frank.hess_at_[hidden]> 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).


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