I have a C++ class that looks something like the following:
void myMethod(int i, int j);
and an instance variable
> foo f
I want to be able to call myMethod of that specific instance (i.e, f.myMethod(1,2) ) from ChaiScript.
After following the descriptions in the cheatsheet for registering methods, running into a compile error “Multiple overloads of ‘handle’ instantiate to the same signature…”, hunting through StackOverflow for a solution, I finally came up with the following way to register the method
chai.add(chaiscript::fun(static_cast<void (foo::*)(int, int)>(&foo::myMethod)), "f");
This is clearly not right as the actual instance is not included anywhere. How is this supposed to work?
Thanks in advance.
NB - I’ve tried replacing &foo::myMethod with things like &this->myMethod but I just get various other syntax errors