logical_and, boost::bind, and boost::function
I'm trying to use boost::bind and boost::function with std::logical_not
and I've run into some strange template magic that I don't understand.
In the example below, I use boost::function to help compose several
boost::bind calls so that I don't have to do it all on one line (I find
that this improves readability). The problem is that when I do this,
the functions that are bound with boost::bind never get called. They
will get called only if I construct everything on one line. (???)
Is this expected behavior? If so, why does it work like this?
Thanks,
aaron
#include <algorithm>
#include <functional>
#include "boost/bind.hpp"
#include "boost/function.hpp"
using namespace std;
using namespace boost;
class test {
public:
void bindtest() {
// test1: composed gradually for clarity
//
function
On Aug 10, 2005, at 11:44 AM, Simmons, Aaron wrote:
function
funcFoo = bind(&test::foo, this); function funcBar = bind(&test::bar, this); function 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
participants (2)
-
Douglas Gregor
-
Simmons, Aaron