|
Boost Users : |
Subject: [Boost-users] [bind] member function as signal handler
From: Tim Odenthal (Tim.Odenthal_at_[hidden])
Date: 2011-06-17 12:22:07
Hi, all!
I'd like to get a member function of an object to handle signals - is
that possible with boost::bind?
I tried the following, which doesn't work:
SomeClass{
...
bool done_;
public:
void handler_done(int signal){
std::cout << "Recieved signal " << signal <<" ..." <<std::endl;
done_ = true;
}
};
then, in the main:
#include <signal.h>
#include <boost/bind.hpp>
...
SomeClass someClass;
signal( SIGINT,boost::bind( &SomeClass::handler_done, &someClass,_1) );
...
I get the following error (g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3):
error: cannot convert boost::_bi::bind_t<void, boost::_mfi::mf1<void,
SomeClass, int>, boost::_bi::list2<boost::_bi::value<SomeClass*>,
boost::arg<1> > > to void (*)(int) for argument 2 to void (*
signal(int, void (*)(int)))(int)
Is this generally impossible, or am I just making some stupid error from
not really understanding boost::bind properly?
Thanks in advance!
Tim
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