Registering overloaded bound member functions


#1

Hello,

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?


#2

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");