Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I wrap functions which take C++ containers as arguments?

containers functions Wrap
0
10 Posted

How can I wrap functions which take C++ containers as arguments?

0
10

Ralf W. Grosse-Kunstleve provides these notes: • Using the regular class_<> wrapper: class_ >(“std_vector_double”) .def(…) … ; This can be moved to a template so that several types (double, int, long, etc.) can be wrapped with the same code. This technique is used in the file scitbx/include/scitbx/array_family/boost_python/flex_wrapper.h in the “scitbx” package. The file could easily be modified for wrapping std::vector<> instantiations. This type of C++/Python binding is most suitable for containers that may contain a large number of elements (>10000). • Using custom rvalue converters. Boost.Python “rvalue converters” match function signatures such as: void foo(std::vector const& array); // pass by const-reference void foo(std::vector array); // pass by value Some custom rvalue converters are implemented in the file scitbx/include/scitbx/boost_python/container_conversions.h This code can be used to convert from C++ container types such as std::v

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123