Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++11 带有std::vector::at的luabind返回值';试图使用未注册的类';_C++11_Lua_Luabind - Fatal编程技术网

C++11 带有std::vector::at的luabind返回值';试图使用未注册的类';

C++11 带有std::vector::at的luabind返回值';试图使用未注册的类';,c++11,lua,luabind,C++11,Lua,Luabind,我正在尝试将luabind与std::vector一起使用。我将GCC4.8.1与c++11一起使用。转换代码如下所示 template <typename T> void luabindVector(lua_State* S, std::string tname) { module(S)[class_<std::vector<T> >(tname.c_str()).def(constructor<>()).def( "pushBa

我正在尝试将luabind与std::vector一起使用。我将GCC4.8.1与c++11一起使用。转换代码如下所示

template <typename T>
void luabindVector(lua_State* S, std::string tname) {
module(S)[class_<std::vector<T> >(tname.c_str()).def(constructor<>()).def(
        "pushBack",
        static_cast<void (std::vector<T>::*)(
                const T&)>(&std::vector<T>::push_back)).
                def("at",(T& (std::vector<T>::*)(size_t))(&std::vector<T>::at)).
                def("resize",static_cast<void (std::vector<T>::*)(size_t)>(&std::vector<T>::resize)).
                def("size",&std::vector<T>::size).
                def("assign",static_cast<void (std::vector<T>::*)(size_t, const T&)>(&std::vector<T>::assign))];
}
这将产生错误std::runtime_error:“尝试使用未注册的类”,错误为2

请注意,push_back、resize、size和assign都可以正常工作,但是程序在调用tans:at(1)时失败。从文档中不清楚我应该如何正确地做到这一点。有人知道我做错了什么吗

luabindVector<double>(L,"vectorDouble");
tans = vectorDouble()
tans:resize(3)
a=tans:at(1)