[C++-sig] Boost.Python v2: implicit conversion support

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Tue Mar 26 19:23:39 CET 2002


--- David Abrahams <david.abrahams at rcn.com> wrote:
> Support for C++ implicit conversions has now been added to the v2
> codebase. Please see libs/python/test/implicit.* for examples.

Cool!
Could this mechanism also be used to convert, e.g., python tuples
to std::vector?

implicitly_convertible<boost::python::tuple, std::vector<double> >();

I guess not since there is no appropriate C++ implicit conversion.
What about something like this:

struct my_converter_type {
  operator()(const boost::python::tuple& t, std::vector<double>& v) const
  {
    // convert the elements of the tuple and store in v
  };
};

implicitly_convertible<
  boost::python::tuple,
  std::vector<double>,
  my_converter_type>();

Thanks,
        Ralf


__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®
http://movies.yahoo.com/




More information about the Cplusplus-sig mailing list