Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.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++ luabind';试图使用未注册的类';返回时_C++_Lua_Luabind - Fatal编程技术网

C++ luabind';试图使用未注册的类';返回时

C++ luabind';试图使用未注册的类';返回时,c++,lua,luabind,C++,Lua,Luabind,我目前正在使用luabind绑定一个类(确切地说是SFML2.0中的sf::Time),并且我一直从luabind中得到一个异常。以下是我的绑定代码: using namespace luabind; module(L, "system") [ class_<sf::Time>("Time") .def(constructor<>

我目前正在使用luabind绑定一个类(确切地说是SFML2.0中的sf::Time),并且我一直从luabind中得到一个异常。以下是我的绑定代码:

            using namespace luabind;

            module(L, "system")
            [
                class_<sf::Time>("Time")
                    .def(constructor<>())
                    .def("toSeconds", &sf::Time::asSeconds)
                    .def("toMilliseconds", &sf::Time::asMilliseconds)
                    .def("toMicroseconds", &sf::Time::asMicroseconds)
                    .def(self == other<sf::Time>())
                    .def(self < other<sf::Time>())
                    .def(self <= other<sf::Time>())
                    .def(self - other<sf::Time>())
                    .def(self + other<sf::Time>())
                    .def(self * float())
                    .def(self / float())
                    .scope
                    [
                        def("seconds", &sf::seconds),
                        def("milliseconds", &sf::milliseconds),
                        def("microseconds", &sf::microseconds)
                    ],
...
sf::seconds的签名为:

sf::Time sf::seconds(float)
我已经尝试将对sf::seconds的调用封装在我自己的返回sf::Time的函数中,并且尝试使用sf::Time*作为返回值。不管怎样,我总是犯错误

有什么想法吗

编辑:


我已经自己测试了这个类,我可以使用system.Time()在Lua中创建它,没有问题。所有方法都正常工作,但system.Time.seconds和其他静态方法不工作。

您从Lua/Luabind得到的错误是什么?我上面说过……'STD::RunTimeOrth:使用未注册类“如果不使它们静态”会发生什么?它们(秒/毫秒/微秒)甚至不是C++中类的一部分。它们只是名称空间sf中的函数。是的,我试着把它们移到时间课之外。它们之所以存在,是因为我认为system.Time.seconds比system.seconds更有意义。因为我无法理解这一点,所以我干脆删除了Time类。我现在只是用一个浮点数来表示秒数。
sf::Time sf::seconds(float)