Boost logo

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.

#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;

    void assign() {
        func = boost::bind(&Object::runner, this, _1);

int main(int argc, char **argv) {
    Object obj;
    func("my message");
    return 0;

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at