c++ - How to pass class/structure instances as arguments to callbacks using boost::bind? -
i looking , stuck on issue of passing class , structure instances arguments call functions using boost::bind
so far call using this method works fine. want use shown below code snippets
class { public : static int = 1; };
however, want pass class instance call function pointer described below
void init(void (*notify)(a *a, int, int,int),int arr[], *a, value,int left,int right) { }
you cannot use boost bind directly this. init
function requires pointer free function having signature:
void (*)(a *a, int, int, int)
so implement 1 this:
void foo(a *a, int x, int y, int z) { a->whatever(x, y, z); }
you'd call init(foo, ...)
.
but have free function; equivalent boost bind expression not work:
boost::bind(&a::whatever, _1, _2, _3)
why won't work? because init
requires free function, not e.g. boost::function<void(a*,int,int,int>)>
support boost::bind
.
Comments
Post a Comment