[C++-sig] On wrapping vector<pair<string, double> >

Zhang Le ejoy at 163.com
Tue Sep 30 08:46:40 CEST 2003

  I'm trying to wrap a function that takes a vector<pair<string, double> >
  as input and return a list. The original function is
   vector<double> eval(const vector<pair<string, double> >&);

   to use boost python, I write a wrapper function:
   python::list py_eval(python::tuple input) {
          here I want to use python::extract<std::string>(input[i][0])
          and python::extract<double>(py_context[i][1])
          to transform python input [('A', 1.0), ('B', 2.0), ...]
          into a new vector<pair<string, double> > for calling real

   Compilation is ok and I get an error in python code:
   obj.py_eval([('A', 1.0), ('B', 2.0)])
   TypeError: No registered converter was able to produce a C++ rvalue
   of type j from this Python object of type str

   I change the declaration to python::list input, python::object input
   and get the same error result.

   Am I missing anything?

                                     Sincerely yours,
                                            Zhang Le

More information about the Cplusplus-sig mailing list