views:

510

answers:

1

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.

+8  A: 
function<void (LuaState&)> on_whatever
    = bind(&my_class::my_method, &my_object_of_type_my_class, _1);
avakar
Hmm I didn't think of that. Let me try it out.
jameszhao00
Shouldn't it be the following?bind(
jameszhao00
Yes, you're right, it should. Fixed.
avakar
that depends on the arguments you need to pass to the method and where do you want to take then from. Read boost::bind documentation.
fnieto
Obviously, he needs to pass a reference to an object of type `LuaState`. ;-)
avakar