Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-08-18 09:35:25


From: "Mark Rodgers" <mark.rodgers_at_[hidden]>
> > Not good. Do you have a better idea?
>
> We could take just those templates which overlap and place them into a
> separate header included by functional.hpp and mem_fun.hpp.

Yes, we could do that, provided that you like the idea; functional.hpp is
your library. I, personally, think that keeping functional.hpp stable is
probably important for the existing user base; also, not that mem_fun.hpp
uses member templates and functional.hpp does not, AFAICS, so this may be a
portability problem.

My other suggestion is:

* I'll refactor bind.hpp so that it doesn't define boost::mem_fun (only
mem_fun.hpp will.) This solves the problem for the users that want to use
bind.hpp and functional.hpp.

* The functional.hpp mem_fun definition can be surrounded by

#ifndef BOOST_FUNCTIONAL_NO_MEM_FUN
#endif

for users that want to use bind.hpp, mem_fun.hpp and the rest of
functional.hpp.

* Optionally, I can make mem_fun rename-able (via #define BOOST_MEM_FUN
something) for users that insist on using everything at once, although I
don't think that would be necessary.

> Yes, but where you write
>
> bind( &X::f, _1, _2 )
>
> what you really want (I believe) to write is
>
> _1->f( _2 )
>
> and it's just that you can't do this. I think the name should reflect
what
> you are really trying to do - call a function. "bind" is a complete
> misnomer.

That's why I prefer mem_fun(&X::f) in this specific case. :-)

Isn't it ironic that my earlier expression.hpp library used 'apply' instead
of 'bind' for this operation? Now I'm convinced that 'bind' is a better name
overall (all uses taken into account.)

--
Peter Dimov
Multi Media Ltd.

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