Closed Sygmei closed 8 years ago
Yes. can it.
please try addMemberFunction to same name
struct Foo {
void func() { std::cout << 1 <<std::endl; }
void func(int param) { std::cout << param <<std::endl; }
};
state["Foo"].setClass(kaguya::ClassMetatable<Foo>()
.addMemberFunction("func", static_cast<void (Foo::*)()>(&Foo::func))
.addMemberFunction("func", static_cast<void (Foo::*)(int)>(&Foo::func))
);
state["foo"] = Foo();
state("foo:func()");//1
state("foo:func(64)");//64
);
or addStaticField with kaguya::overload()
state["Foo"].setClass(kaguya::ClassMetatable<Foo>()
.addStaticField("func", kaguya::overload(static_cast<void (Foo::*)()>(&Foo::func) , static_cast<void (Foo::*)(int)>(&Foo::func))
);
Thanks :)
Can I do an "addMember" of an overloaded method in kaguya ? If not, is it possible to add this feature ?