converting std::queue to a native python type #3681
-
I have a library with a class that exposes a So, before I go off the into deep end trying various methods of converting The resulting python type does not need to be a live reference to the C++ side, but it would help future proof the binding that I'm working on. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
If you just want to cast a queue to a list, you can just add a typecaster or extend the typecaster in stl.h: pybind11/include/pybind11/stl.h Line 175 in ffa3468 Interestingly, we have a caster for std::deque, but not std::queue. Apparently, stack and queue are usually implemented as restricted container adapters of deque. I suppose we should consider adding them: pybind11/include/pybind11/stl.h Line 175 in ffa3468 |
Beta Was this translation helpful? Give feedback.
If you just want to cast a queue to a list, you can just add a typecaster or extend the typecaster in stl.h:
pybind11/include/pybind11/stl.h
Line 175 in ffa3468
Interestingly, we have a caster for std::deque, but not std::queue. Apparently, stack and queue are usually implemented as restricted container adapters of deque. I suppose we should consider adding them:
pybind11/include/pybind11/stl.h
Line 175 in ffa3468