[C++-sig] type conversion

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Fri Feb 6 21:00:44 CET 2004

--- Uwe Schmitt <schmitt at num.uni-sb.de> wrote:
> how can I instruct boost to convert std::pair<int,int> to a
> Python tuple ??? I did not find anything in the archive...

Converting to a Python tuple is easy:


In anticipation of the next question, "how can I do it the other way around",
you can do that with a "custom converter". It's a bit tricky but not actually
hard. Here is the solution for a similar problem:


This technique is very powerful if you have may functions with
std::pair<int,int> as an argument. If you only have a few it is easier to write
"thin wrappers" for your functions or member functions. E.g.:


This is not the best example but I hope you get the idea. It should be obvious
after reading the tutorial.


Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.

More information about the Cplusplus-sig mailing list