Registering overloaded bound member functions



First of all, I’m in love with chai script. Awesome work! :grinning:

I’m having trouble getting overloaded bound member functions registered.

Here’s the code I’m using for overloaded functions

chai.add(chaiscript::fun<void, MyClass, const string&>(&MyClass::SetHeader), “SetHeader”);

Tried this, but it’s not working

chai.add(chaiscript::fun<void, MyClass, const string&>(&MyClass::SetHeader, MyClass_Instance_Ptr), “SetHeader”);

Any thoughts?


You should use a lambda instead, for overloads, it’s much easier to work with:

chai.add(chaiscript::fun([](MyClass *, const string &str){ MyClass->setHeader(str); }), "SetHeader");