简体   繁体   English

Boost.Python-是否不对C ++使用任何Boost?

[英]Boost.Python - Without using any boost for C++?

I have developed a library in C++ (native) and have not used boost in any of the bindings. 我已经用C ++(本机)开发了一个库,并且没有在任何绑定中使用boost。

I'm using Python to create a Wrapper for this library so it can work client-side. 我正在使用Python为此库创建包装器,以便它可以在客户端工作。 After looking at all of the available options to me, it was decided that boost.python was the chosen method. 在查看了我所有可用的选项之后,决定选择boost.python作为方法。 The question is whether or not I can use boost.python for the Python/client side of this, even though I did not use boost in any of the C++ implementation? 问题是,即使我没有在任何C ++实现中使用boost,我是否也可以在Python /客户端使用boost.python

Also, assume that my library is called myLib is it therefore possible to have: 另外,假设我的库名为myLib ,则可能具有:

myLib.Vector() where I can push values to it? myLib.Vector()可以在其中推送值吗? ie vect = myLib.Vector(1, 2, 3, 4, 5) vect = myLib.Vector(1, 2, 3, 4, 5)

Without having to create a class called Vector inside of the C++ library? 无需在C ++库中创建一个称为Vector的类?

Any help would be greatly appreciated 任何帮助将不胜感激

You can use boost.python and ignore the rest of boost. 您可以使用boost.python并忽略其余的boost。

You can explicitely instantiate a vector template specialization in a .cpp file 您可以在.cpp文件中显式实例化矢量模板特化

template class vector<int>;

and later expose it in your python code: 然后在您的python代码中公开它:

class_<...>("Vector").def(...);

This way it should work. 这样,它应该可以工作。

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

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