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的列表獲取返回值?