Embedding python in C++ Code to pass stl containers by reference
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