pybind11 icon indicating copy to clipboard operation
pybind11 copied to clipboard

Embedding python in C++ Code to pass stl containers by reference

Open singhanubhav2000 opened this issue 8 years ago • 0 comments

I have a usecase where I have implemented an API in python and it needs to return struct, vector or map to C++. Could you please help me with an example how to do that. All the usecases I see in pybind is just simply python being embedded in C++ without any return value. The scenario which I need to implement is a python -> C++ interface where the C++ caller will start a session and call various python objects when it wants and then close the session. Any help would be highly appreciated.

I tried to implement the solution as given under the link (http://zpz.github.io/embedding-python-in-cpp-3) scenario 3 but that is failing for me with the error: [root@scspa0521148001 py4cc]# ./main === pass as &x ===

before cumsum, in C++ --- [1, 3, 5] terminate called after throwing an instance of 'pybind11::cast_error' what(): make_tuple(): unable to convert argument of type 'std::vector<int, std::allocator >*' to Python object Aborted (core dumped)

py4cc.zip

singhanubhav2000 avatar Aug 29 '18 21:08 singhanubhav2000