[C++-sig] register c++ std::pair<string, string> and std::pair<string*, string*>

MM finjulhich at gmail.com
Fri Aug 28 13:49:53 CEST 2015


I expose the return type of a C++ function that is a pair of strings with
the following snippet:

to_python_converter<
    std::pair<std::string, std::string>,
    Converter>();

Later, I have a unrelated C++ range type:

typedef std::pair<const std::string*,const std::string*> range_t;

which I export as:

class_<range_t>("range")
    .def("__iter__" , range(..., ...));
scope().attr("allitems") = object(ptr(&R));

where R is of type range_t

in python, allitems can be iterated over.

The only issue is I get the following warning:

/usr/lib64/python3.4/importlib/_bootstrap.py:321: RuntimeWarning:
to-Python converter for std::pair<std::string const*, std::string
const*> already registered; second conversion method ignored.

Is there a way to avoid this warning?

MM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20150828/b3a7004e/attachment.html>


More information about the Cplusplus-sig mailing list