I'm attempting to replace an existing implementation of a queue class written in Lua with the STL Queue class. I'm not sure why this is failing, or how to approach fixing it. Below is some sample code that exhibits the same behavior, along with the error output. Thanks in advance!
#include <luabind/luabind.hpp> #include <queue> struct XYZ_T { short x, y, z; }; typedef std::queue<XYZ_T> XYZ_QUEUE_T; extern "C" int init(lua_State *L) { using namespace luabind; open(L); module(L) [ class_<XZY_T>("XYZ_T") .def(constructor<>()) .def_readwrite("x", &XYZ_T::x) .def_readwrite("y", &XYZ_T::y) .def_readwrite("z", &XYZ_T::z), class_<XYZ_QUEUE_T>("XYZ_QUEUE_T") .def(constructor<>()) .def("push", &XYZ_QUEUE_T::push) .def("pop", &XYZ_QUEUE_T::pop) .def("front", &XYZ_QUEUE_T::front) .def("back", &XYZ_QUEUE_T::back) .def("empty", &XYZ_QUEUE_T::empty) .def("size", &XYZ_QUEUE_T::size) ]; }
And the gcc output:
g++ -o test_luabind.os -c -fPIC -Iinclude -I$VALID_INCLUDE_DIR /packages/build_env/include test_luabind.cpp test_luabind.cpp: In function `int init(lua_State*)': test_luabind.cpp:27: error: no matching function for call to ` luabind::class_<XYZ_QUEUE_T, luabind::detail::unspecified, luabind::detail::unspecified, luabind::detail::unspecified>::def(const char[6], <unknown type>)' test_luabind.cpp:32: error: parse error before `(' token
Most likely, you have an overloaded function in your queue implementation. Thus, when you take the address, the compiler doesn't know what to do because you could mean any overloaded function.