Boost logo

Boost Users :

From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2005-08-10 12:42:05


On Aug 10, 2005, at 11:44 AM, Simmons, Aaron wrote:
>         function<bool ()> funcFoo  = bind(&test::foo, this);
>         function<bool ()> funcBar  = bind(&test::bar, this);
>         function<bool ()> funcTest1= bind(logical_and<bool>(),
> funcFoo, funcBar);

Alan's post made me realize what's happening. Indeed, this last bind()
doesn't know that funcFoo and funcBar are functions that it should
call. You can tell it to consider them as functions by calling bind()
on them:

        function<bool ()> funcTest1= bind(logical_and<bool>(), bind(funcFoo),
bind(funcBar));

Now it should work fine. Whether it's actually clearer or not is for
you to decide, but here's one warning: each call through a
boost::function object is like a virtual function call. So by turning
each call to one boost::function object into a call through 3
boost::function objects, there will be a performance penalty.

        Doug


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net