How to expose std::pair
to python using boost::python
? When I expose for example vector<string>
I simply write:
class_<std::vector<std::string> >("StringVec")
.def(vector_indexing_suite<std::vector<std::string> >())
;
But I don't know how to deal with std::pair.
I found a solution. The most simple example of exposing std::pair
is:
class_<std::pair<int, int> >("IntPair")
.def_readwrite("first", &std::pair<int, int>::first)
.def_readwrite("second", &std::pair<int, int>::second);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With