[英]Luabind compile time error Unable to deduce template argument
我得到了我不理解的编译时错误列表。 我正在使用sourceforge(版本0.9.1)中的luabind库,并且试图绑定MyGUI中的函数,正在使用Visual Studio 2012和Lua 5.1。 尽管似乎源自其他文件,但在以下cpp代码的编译过程中会出现错误。 这些错误使我觉得我没有在某处正确定义签名,但是我的IntelliSense并未指出任何此类问题。
有问题的代码:
LuaMachine.cpp (Stackoverflow抱怨体长,所以我把它放在pastebin上)
给出的错误:
Error 4 error C2780: 'void luabind::detail::value_wrapper_converter<U>::apply(lua_State *,const T &)' : expects 2 arguments - 3 provided c:\users\jake kiesel\space-junk\c++ project\3rdpartycode\include\luabind\detail\call.hpp 293 1 Space Junk
Error 3 error C2784: 'int luabind::detail::value_wrapper_converter<U>::match(lua_State *,luabind::detail::by_const_reference<T>,int)' : could not deduce template argument for 'luabind::detail::by_const_reference<T>' from 'luabind::detail::by_reference<T>' c:\users\jake kiesel\space-junk\c++ project\3rdpartycode\include\boost\preprocessor\iteration\detail\local.hpp 34 1 Space Junk
Error 2 error C2784: 'int luabind::detail::value_wrapper_converter<U>::match(lua_State *,luabind::detail::by_value<T>,int)' : could not deduce template argument for 'luabind::detail::by_value<T>' from 'luabind::detail::by_reference<T>' c:\users\jake kiesel\space-junk\c++ project\3rdpartycode\include\boost\preprocessor\iteration\detail\local.hpp 34 1 Space Junk
Error 6 error C2784: 'T luabind::detail::value_wrapper_converter<U>::apply(lua_State *,luabind::detail::by_const_reference<T>,int)' : could not deduce template argument for 'luabind::detail::by_const_reference<T>' from 'luabind::detail::by_reference<T>' c:\users\jake kiesel\space-junk\c++ project\3rdpartycode\include\luabind\detail\call.hpp 293 1 Space Junk
Error 5 error C2784: 'T luabind::detail::value_wrapper_converter<U>::apply(lua_State *,luabind::detail::by_value<T>,int)' : could not deduce template argument for 'luabind::detail::by_value<T>' from 'luabind::detail::by_reference<T>' c:\users\jake kiesel\space-junk\c++ project\3rdpartycode\include\luabind\detail\call.hpp 293 1 Space Junk
编辑:
通过进一步的研究,我发现了以下引发这些错误的问题线。 这些行在wrapGuiManager函数中。
luabind :: def(“ destroyWidgets”,&MyGUIManager :: destroyWidgets)
luabind :: def(“ unloadLayout”,&MyGUIManager :: unloadLayout),
这些是这些函数的函数声明:
void unloadLayout(luabind :: object&table);
void destroyWidgets(luabind :: object&table);
这两个函数的独特之处在于它们都带有luabind :: object&参数。 他们应该能够从Lua中获取一个表,该表用作充满MyGUI小部件的数组。
我懂了! :D问题线是
luabind::def("destroyWidgets", &MyGUIManager::destroyWidgets)
和
luabind::def("unloadLayout", &MyGUIManager::unloadLayout)
这两个函数都使用luabind::object&
,但是luabind不想与它们合作,而是希望这些函数采用不带引用的luabind::object
,而只是对象本身。 因此正确的函数声明为:
void unloadLayout(luabind::object table);
void destroyWidgets(luabind::object table);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.