问题描述
我有一个单身(自boost ::序列化):
I have a singleton (from boost::serialization):
class LogManager : public boost::serialization::singleton<LogManager> { ... };
和包装获取例如:
inline LogManager &logManager() { return LogManager::get_mutable_instance(); }
什么是绑定到Boost.Python的模块的正确方法?
What's the right way to bind this into boost.python module?
我试过:
class_< LogManager, boost::serialization::singleton<LogManager> >("LogManager", no_init)
...
;
结果 - 很多在控制台难看的错误文字。怎么了?
As a result - a lot of ugly error text in console. What's wrong?
推荐答案
在除了使用基地&LT; ...&GT;
在第二个参数作为Autopulated指出,我想你也想specifiy 的boost ::不可复制
作为第三个模板参数,如:
In addition to using bases<...>
in the second argument as Autopulated pointed out, I think you also want to specifiy boost::noncopyable
as the third template argument, e.g.
bp::class_<LogManager, bp::bases<boost::serialization::singleton<LogManager> >, boost::noncopyable>("LogManager", bp::no_init)
修改:
另外,你需要对列出的任何基类类声明,例如
Edit:Also, you need have a class declaration for any base classes listed, e.g.
bp::class_<boost::serialization::singleton<LogManager>, boost::noncopyable>("Singleton", bp::no_init)
或者,如果你不需要访问的基类,不会被输出的boost ::系列化::单中任何其他的孩子;日志管理&GT;
,那么你可以省略摆在首位指定基类。也就是说,下面的声明还是蛮好的,如果你想要做的就是揭露日志管理
类:
Or, if you don't need access to the base class and won't be exporting any other children of boost::serialization::singleton<LogManager>
, then you can omit specifying the base classes in the first place. That is, the following declaration is just fine if all you want to do is expose the LogManager
class:
bp::class_<LogManager, boost::noncopyable>("LogManager", bp::no_init)
这篇关于升压蟒蛇出口单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!