[C++-sig] implicit_convertible extension
Stefan Seefeld
stefan.seefeld at orthosoft.ca
Wed Jul 16 15:28:49 CEST 2003
hi there,
I'm browsing through the documentation as well as
the mailing list archive to find the best way to
convert between a C++ type (boost::posix_time::time_duration)
and a python type (double).
Conversion should happen implicitely, i.e. I have a bunch
of functions taking a time_duration argument, which I want
to be able to call in python passing simple doubles.
Looking at the documentation for implicit_convertible,
I find the requirements a bit restrictive.
I think it may be convenient to be able to provide converter
functions that do the conversion even if the two types themselfs
are totally unaware of each other (i.e. no cast operators, no
special constructors required).
Then, instead of saying
implicitly_convertible<X, double>();
implicitly_convertible<double, X>();
I would expect to say
X double_to_X(double);
double X_to_double(const X &);
...
implicitly_convertible<X, double>(X_to_double);
implicitly_convertible<double, X>(double_to_X);
Does this make any sense ? Does something like this already exist ?
Thanks,
Stefan
More information about the Cplusplus-sig
mailing list