1
如何註冊依賴於移動語義的方法和使用chaiscript引擎的std::unique_ptr
?下面是一個代碼示例一塊,我不能讓使用chaiscript 5.8.5工作:在chaiscript中移動語義和std :: unique_ptr
class Element;
class MyClass
{
public:
void addElement(std::unique_ptr<Element>&&);
};
chaiscript::ModulePtr m = chaiscript::ModulePtr(new chaiscript::Module());
chaiscript::utility::add_class<MyClass>(*m, "MyClass", {
chaiscript::constructor<MyClass()>()
}, {
{chaiscript::fun(&MyClass::addElement), "addElement"},
});
這從chaiscript中生成以下錯誤:
dispatchkit/boxed_cast_helper.hpp:43:46: error: 'type name' declared as a pointer to a reference of type 'std::__1::unique_ptr std::__1::default_delete > &&' return *static_cast(p);