I have a class that I want to associate with lua. The abbreviated code may be:
class CSprite2D{ void setPosition(glm::ivec2 val) { m_position = val; } void setPosition(int posX, int posY) { m_position.x = posX; m_position.y = posY; } static void exposeAPI(lua_State* L,const unsigned char* data) { assert(L); luabind::module(L)[ luabind::class_<CSprite2D>("CSprite2D") .def("setPosition",(void(*)(int,int))&CSprite2D::setPosition) ]; }
When I try to compile, the compiler also throws errors:
Error 1 error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'void (__cdecl *)(int,int)' c:\directo\gameprojects2008\zeleste2d\src\graphics\gpx\sprite2d.cpp 74 Error 2 error C2780: 'luabind::class_<T> &luabind::class_<T>::def(luabind::detail::operator_<Derived>)' : expects 1 arguments - 2 provided c:\directo\gameprojects2008\zeleste2d\src\graphics\gpx\sprite2d.cpp 74 Error 3 error C2784: 'luabind::class_<T> &luabind::class_<T>::def(luabind::detail::operator_<Derived>,const Policies &)' : could not deduce template argument for 'luabind::detail::operator_<Derived>' from 'const char [12]' c:\directo\gameprojects2008\zeleste2d\src\graphics\gpx\sprite2d.cpp 74 Error 4 error C2784: 'luabind::class_<T> &luabind::class_<T>::def(luabind::constructor<A0,A1,A2,A3,A4,A5,A6,A7,A8,A9>,const Policies &)' : could not deduce template argument for 'luabind::constructor<A0,A1,A2,A3,A4,A5,A6,A7,A8,A9>' from 'const char [12]' c:\directo\gameprojects2008\zeleste2d\src\graphics\gpx\sprite2d.cpp 74 Error 5 error C2780: 'luabind::class_<T> &luabind::class_<T>::def(luabind::constructor<A0,A1,A2,A3,A4,A5,A6,A7,A8,A9>)' : expects 1 arguments - 2 provided c:\directo\gameprojects2008\zeleste2d\src\graphics\gpx\sprite2d.cpp 74 Error 6 error C2780: 'luabind::class_<T> &luabind::class_<T>::def(const char *,F,Default,const Policies &)' : expects 4 arguments - 2 provided c:\directo\gameprojects2008\zeleste2d\src\graphics\gpx\sprite2d.cpp 74 Error 7 error C2780: 'luabind::class_<T> &luabind::class_<T>::def(const char *,F,DefaultOrPolicies)' : expects 3 arguments - 2 provided c:\directo\gameprojects2008\zeleste2d\src\graphics\gpx\sprite2d.cpp 74
I know that the reason for the problem is that luabind could not output the best overload function, but reading the luabind documentation I define the function correctly in luabind.
Any ideas?
Thank you in advance