Details
-
Type:
Improvement
-
Status: To Do
-
Resolution: Unresolved
-
Fix Version/s: None
-
Component/s: None
-
Labels:
-
Story Points:1
Description
While wrapping some some jointcal C++ to write python tests for it, I discovered pybind11's stl_bind.h opaque wrappers. This did the job for me, but it was not recommended by our pybind11 gurus, for various reasons. We don't mention it in the stl section of the dev guide, although we do have two related mentions of wrapping stl types in the pybind11 style guide:
https://developer.lsst.io/coding/pybind11_style_guide.html#default-automatic-conversions-shall-be-used-for-all-stl-containers
https://developer.lsst.io/coding/pybind11_style_guide.html#where-copying-of-stl-containers-is-undesirable-an-ndarray-type-should-be-used-instead
Please add a note to the dev guide stl section about why not to use the stl_bind-style opaque wrappers, since that's the obvious place to look when wondering about wrapping stl objects. It might be worth adding an example that returns the object via a C++ lambda (if we don't have such an example already), e.g.:
cls.def("getMappingIndices", [](PhotometryMappingBase const &self) {
|
std::vector<unsigned> indices(0);
|
self.getMappingIndices(indices);
|
return indices;
|
});
|
I don't know enough about this issue to feel comfortable documenting it.