Boost logo

Boost :

From: Jesse Jones (jesjones_at_[hidden])
Date: 2000-11-23 18:42:02


>>>>>(3) Not implement reference in the function_ptr at all.
>[...]
>>> shared_ptr< function_ptr<void> > s(new_function_ptr(f));
>>> ...
>>> s();
>>
>>Sure, but if 99% of the time I'm wrapping function_ptr up in a shared_ptr
>>I'd begin to wonder why I couldn't just copy the damned callback object.
>
>I've not found the need (where "want" and "need" are not the same idea
>;->) to use anything but cloning, so I would be suspicious of figures
>like 99%... or indeed 9.9%. This is not to say that the need does not
>arise, just that I would not wish to bend the class out of shape when we
>already have a clear and acceptable solution to that situation above.
>
>If someone can demonstrate the need _and_ that the need is common (and
>the distinction between "want" and "need" is again important), then it
>may be worth pursuing an internal solution. As it stands, the more
>orthogonal solution suits me fine, and keeps things simpler by
>eliminating the issues.

My callback usage almost always looks something like this:

   mPushButton = new PushButton(...);

   boost::callback<void> callback(this, &MyObject::OnClicked);
   mPushButton->SetNotifier(callback);

This pretty much mandates at least one copy. It's true that I don't
*need* to have callbacks be copyable, but if they're not I think I'll
always be wrapping them up with shared_ptr which seems silly.

  -- Jesse


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk