0
的C++代码如下:暴露C++函数到Python
struct A {
A(int x, int y):a(x),b(y){}
int a;
int b;
};
std::vector<A> get_a(const A& a1, const A& a2);
使他们面临的Python:
建立这些代码放到一个hello.pyd。并呼吁get_a在Python代码:
import hello
a1 = hello.A(1,2)
a2 = hello.A(3,4)
hello.get_a(a1, a2)
,但是这是行不通的:
Boost.Python.ArgumentError: Python argument types in
hello.get_a(Boost.Python.class, Boost.Python.class)
did not match C++ signature:
get_a(class A, class A)
我还没有发现有用的信息在Boost.Python的文档了解如何通过自定义的对象,如何去做这个?我猜std :: vector的返回类型也不会自动处理。如何让python的列表获取返回值?