简体   繁体   English

如何从boost.python使用class_的参数

[英]how to use parameters of class_ from boost.python

The first question: The class_ class has four parameters. 第一个问题:class_类具有四个参数。

class template class_<T, Bases, HeldType, NonCopyable>

I don't understand the parameters of Bases and HeldType.How to use the parameters. 我不了解Bases和HeldType的参数。如何使用这些参数。 this doc: http://www.boost.org/doc/libs/1_51_0/libs/python/doc/v2/class.html 此文档: http : //www.boost.org/doc/libs/1_51_0/libs/python/doc/v2/class.html

The second question: I have to make a python function as callback of a c++ function.How to do?Where can I find some examples?? 第二个问题:我必须做一个python函数作为c ++函数的回调,怎么办?在哪里可以找到一些例子?

The HeldType is usefull, if you want to use a special object to hold your object. 如果要使用特殊对象来保存对象,则HeldType很有用。 For eg if you use shared_ptr<> inside your implementation you can use this as HeldType. 例如,如果您在实现中使用shared_ptr <>,则可以将其用作HeldType。

If you have no idea what shared_ptr are, just google for them, they are a nice tool. 如果您不知道什么是shared_ptr,那么只需谷歌搜索它们,它们就是一个不错的工具。

Further descriptions as an example for the shared_ptr<> as HeldType can be found here: Python Wiki, deailing with smart pointers 可以在此处找到作为shared_ptr <>作为HeldType的示例的进一步说明: Python Wiki,使用智能指针失败

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM