Boost logo

Boost :

Subject: Re: [boost] [function] Problem with simple pointer to function
From: Hans Dembinski (hans.dembinski_at_[hidden])
Date: 2017-01-17 04:22:03


> On 17 Jan 2017, at 10:05, Fu ji <fujimailing_at_[hidden]> wrote:
>
> I have a problem with boost::function, when I try to assign function to
> pointer I have a crash. It is simple void function();

I just tried the following code on http://melpon.org/wandbox, it works fine.

#include <iostream>
#include <boost/function.hpp>

void f(void) {
    std::cout << "Hello World" << std::endl;
}

int main() {
    boost::function<void(void)> bf;
    bf = &f;
    bf();
}

You are also missing critical information, like the boost version that you are using (in my case it was 1.61).

I think your question might be better placed on to the boost-users mailing list:

http://lists.boost.org/mailman/listinfo.cgi/boost-users

Best regards,
Hans


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk