我正在使用 ChaiScript 5.3.1,我正在尝试将函数绑定到我自己的类,特别是一个 setPosition 函数,它可以采用 Vector3 或 3 个浮点数。
该类及其相关方法的声明如下:
class DLLExport Actor
{
public:
Actor(Level* level, const String& name, Actor* parent);
virtual ~Actor();
void setPosition(const Real& x, const Real& y, const Real& z);
void setPosition(const Vector3& position);
};
我正在尝试像这样绑定它们:
m->add(user_type<Actor>(), "Actor");
m->add(fun<void (Actor::*)(const Vector3&)>(&Actor::setPosition), "setPosition");
这会产生以下编译器输出(Windows、MSVC 2013):
2functional(550): error C2027: use of undefined type 'std::_Get_function_impl<_Fty>'
2> with
2> [
2> _Fty=void (__thiscall Actor::* )(const Vector3 &)
2> ]
2> ..\..\ScriptingDemo\Binder.cpp(60) : see reference to class template instantiation 'std::function<void (__thiscall Actor::* )(const Vector3 &)>' being compiled
2functional(551): error C2504: 'type' : base class undefined
2functional(554): error C2027: use of undefined type 'std::_Get_function_impl<_Fty>'
2> with
2> [
2> _Fty=void (__thiscall Actor::* )(const Vector3 &)
2> ]
2functional(554): error C2146: syntax error : missing ';' before identifier '_Mybase'
2functional(554): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int