Boost logo

Boost :

From: Jesse Jones (jesjones_at_[hidden])
Date: 2001-05-03 18:52:36


>Requiring operator== of all function objects used with boost::function would
>be way too strict, I think. We have to be very careful when adding
>requirements for functors in boost::function because they are requirements
>even if not used.

Well you can make it work when the boost::function is pointing to a
free function, a member function pointer, or a functor that supports
operator==. If you got a compile time error when you tried to compare
boost::function's when this didn't hold that would be fine with me.

>I'd argue that you should have one Timer object per callback, and then use a
>static class member to keep track of all of the existing Timer objects to
>call them; no equality test required.

I can see this working, but it would be a bit more complex
(aggravated a bit because I'm using a COM like object model). However
the fact remains that comparing boost::function's is useful and is
exactly the sort of thing you would do with an ordinary function
pointer. This seems like a strong argument for making it part of the
API...

>Why not just:
>-------------------
>// About
>handle->RegisterCommand(kAboutCmd, bind(this, &CApp::DoAbout),
>kDisabledIfDialog);
>
>// Delete Formula
>handler->RegisterCommand(kDeleteFormulaCmd,
> bind(this, &CApp::DoDeleteFormula),
> bind(this, &CAppMenuHandler::DoEnableDeleteFormula));
>
>// Delete palette
>handler->RegisterCommand(kDeletePaletteCmd,
> bind(this, &CApp::DoDeletePalette),
> bind(this, &CApp::DoEnableDeletePalette));
>-------------------
>
>Implicit conversion from any function object/function pointer to a
>boost::function is supported to make all of this easier.

Hmm, I think I could live with that. It's important to make this as
easy to use and as clean as possible though because it'll be used a
lot. I looked at the bind.hpp that Peter pointed me to and it had a
different (and to my eyes uglier) API.

   -- Jesse


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