From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-03-19 11:54:21
From: "Gary Powell" <Gary.Powell_at_[hidden]>
> > bind(f); // gives a library-compatible function object //
> > case 1
> > bind(&Class::member); // ditto, works with Class &, Class *,
> > shared_ptr<Class>, variant<Class>, etc as a first argument. // case 2
> > bind(f, _2, _1); // lambda(x, y, ...) := f(y, x); // case 3
> > bind(f, 4, _, 5); // lambda(x, y, ...) := f(4, x, 5); // case 4
> > bind(_, 1, 2); // labmda(x, ...) := x(1, 2); // case 5
> > bind.hpp, however, is doable
> > (in theory.)
> > I think that we should propose a common interface, to give people a
> > to implement it for the platform they are interested in.
> I think I can speak for Jaakko and I here, and that is yes a common
> interface would be fine. That's part of the reason we broke the LL library
> into the various sections.
> I think the other case you are missing is
> bind(&className::MemberFn, classReference/Pointer, arguments);
> as in bind(&data::foo, f, 1, 2) ==> f->*foo(1,2); // case 6
Yes, I've thought of that as well, just didn't include it in the list.
> The only other case we don't handle this way is case #2. I'm not sure I
> understand what you intend the result of this call to bind to be.
std::for_each(v.begin(), v.end(), bind(&X::f));
bind(&X::f) is basically equivalent to bind(&X::f, _, _, ...) (insert the
number of arguments to X::f here) - it is a direct replacement to mem_fun
> And that the naming convention for the "free" args that the two libraries
> use is different. (LL has a typedefs for the free args so this isn't much
> an issue for LL.)
_1 is my new favorite. :-) I think that it's much better than free1 or arg1.
The single _ (without a number) is very convenient, too.
-- 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