Здравствуйте, adalekin, Вы писали:
A>Доброго времени суток, коллеги!
A> // What do we really need:
A> // runner.run(boost::bind(f, "arg1", "arg2"), true);
A>
#include <tr1/functional>
#include <iostream>
class f_runner
{
public:
void run(std::tr1::function<void ()> f, bool deferred)
{
std::cout << "From runner " << (deferred ? "( deferred ): " : ": ");
f();
}
};
class h
{
public:
void handle(const std::string & a, const std::string & b)
{
std::cout << a << " - " << b;
}
};
int main(int argc, const char * const argv[])
{
f_runner runner;
h handler;
std::tr1::function<void (const std::string &, const std::string &)> f = std::tr1::bind(&h::handle, std::tr1::ref(handler)
, std::tr1::placeholders::_1 , std::tr1::placeholders::_2);
runner.run(std::tr1::bind(f, "arg1", "arg2"), true);
return 0;
}
отлично компилируется и работает как задумано:
http://codepad.org/rka47j4d