[C++-sig] Supporting container conversions
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Mon Jul 8 23:13:01 CEST 2002
> a. Is it worth it?
I could live with the current framework.
It seems unlikely to me that people pass huge Python sequences to C++
on a regular basis. We are using the Python sequence -> container
conversions only for passing tiny arrays. Therefore efficiency is
a very minor concern.
> b. Is there a simpler answer?
As I see it, the main problem are sequences that absolutely have to be
converted in one pass. A simple solution would be to use a function
taking a boost::python::object. In this way overload resolution and
conversion are decoupled. Thinking about it, this is exactly how
people emulate overload resolution in Python (evaluate the type(s) of
the argument(s) inside the function).
The only general solution I can think of is to support an exception-
handling-based protocol for overload resolution. I.e., if construct()
throws an exception of a certain type overload resolution continues as
if the corresponding convertible() test had failed. Wouldn't that be
easy to implement?
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
More information about the Cplusplus-sig