Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ Callbacks using Boost Functions and C++ Class Methods

Is there a non-hacky (i.e. no assembly, ...) way to use boost functions to create callbacks with non-static class methods?

Currently for static methods:

list<function<void (LuaState&)> > _callbacks;

I was thinking something along the lines of

list<tuple<function<void (void *, LuaState&)>, void*> _callbacks;

but boost functions doesn't like those void*s.

like image 518
jameszhao00 Avatar asked Feb 22 '26 11:02

jameszhao00


1 Answers

function<void (LuaState&)> on_whatever
    = bind(&my_class::my_method, &my_object_of_type_my_class, _1);
like image 166
avakar Avatar answered Feb 25 '26 00:02

avakar