Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2004-03-11 11:54:32


On Mar 11, 2004, at 9:42 AM, David Abrahams wrote:

> This surprised me; should it have?
>
> #include <boost/bind.hpp>
> #include <boost/mem_fn.hpp>
>
> struct X
> {
> int y;
> };
>
> int main()
> {
> boost::mem_fn(&X::y); // OK
> boost::bind(&X::y); // Error!
> }

I'm not seeing any surprises. mem_fn(&X::y) produces a function object
that takes one parameter. Therefore the bind equivalent needs an
argument or a placeholder:

bind(&X::y, _1);

-Howard


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