简体   繁体   English

Luabind编译时错误无法推断模板参数

[英]Luabind compile time error Unable to deduce template argument

I'm getting a list of compile time errors that I don't understand. 我得到了我不理解的编译时错误列表。 I'm using the luabind library from sourceforge, version 0.9.1, and I'm trying to bind functions from MyGUI, I'm using Visual Studio 2012, and Lua 5.1. 我正在使用sourceforge(版本0.9.1)中的luabind库,并且试图绑定MyGUI中的函数,正在使用Visual Studio 2012和Lua 5.1。 The errors come up during the compilation of the cpp code below, despite seeming to originate in other files. 尽管似乎源自其他文件,但在以下cpp代码的编译过程中会出现错误。 The errors make me think I didn't define a signature correctly somewhere, however my IntelliSense isn't indicating any such problem. 这些错误使我觉得我没有在某处正确定义签名,但是我的IntelliSense并未指出任何此类问题。

The code in question: 有问题的代码:

LuaMachine.cpp (Stackoverflow complained about body length, so I put it on pastebin) LuaMachine.cpp (Stackoverflow抱怨体长,所以我把它放在pastebin上)

The errors given: 给出的错误:

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

EDIT: 编辑:

Through further research I have discovered the following are problem lines that are triggering these errors. 通过进一步的研究,我发现了以下引发这些错误的问题线。 These lines are in the wrapGuiManager function. 这些行在wrapGuiManager函数中。

luabind::def("destroyWidgets", &MyGUIManager::destroyWidgets) luabind :: def(“ destroyWidgets”,&MyGUIManager :: destroyWidgets)

luabind::def("unloadLayout", &MyGUIManager::unloadLayout), luabind :: def(“ unloadLayout”,&MyGUIManager :: unloadLayout),

These are the function declarations for those functions: 这些是这些函数的函数声明:

void unloadLayout(luabind::object& table); void unloadLayout(luabind :: object&table);

void destroyWidgets(luabind::object& table); void destroyWidgets(luabind :: object&table);

Both of these functions are unique in that they take a luabind::object& parameter. 这两个函数的独特之处在于它们都带有luabind :: object&参数。 They're supposed to be able to take a table from Lua that is used as an array full of MyGUI widgets. 他们应该能够从Lua中获取一个表,该表用作充满MyGUI小部件的数组。

I got it to work! 我懂了! :D the problem lines were :D问题线是

luabind::def("destroyWidgets", &MyGUIManager::destroyWidgets)

and

luabind::def("unloadLayout", &MyGUIManager::unloadLayout)

Both of those functions took luabind::object& , luabind didn't want to cooperate with those though, it instead wanted the functions to take luabind::object without a reference, and just the object itself. 这两个函数都使用luabind::object& ,但是luabind不想与它们合作,而是希望这些函数采用不带引用的luabind::object ,而只是对象本身。 So the correct function declarations would be: 因此正确的函数声明为:

void unloadLayout(luabind::object table);
void destroyWidgets(luabind::object table);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM