簡體   English   中英

Luabind編譯時錯誤無法推斷模板參數

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM