|
Boost Users : |
Subject: Re: [Boost-users] Boost::bind member function and save to function pointer
From: justin allen (justin.d.allen_at_[hidden])
Date: 2011-04-13 20:13:10
you probably really do want to look into an event system that will prescribe
a bit of pre-built organization but if you just want to store the bind for
later boost function will do it.
http://www.boost.org/doc/libs/1_46_1/doc/html/function.html
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <iostream>
boost::function<void (std::string)> func;
class Object {
void runner(std::string message) {
std::cout << message << std::endl;
}
public:
void assign() {
func = boost::bind(&Object::runner, this, _1);
}
};
int main(int argc, char **argv) {
Object obj;
obj.assign();
func("my message");
return 0;
}
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