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

Stefan Seefeld stefan at seefeld.name
Fri Aug 28 14:41:31 CEST 2015


On 28/08/15 07:49 AM, MM wrote:
>
> 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-Pythonconverter
> forstd::pair<std::string const*,std::string const*>already
> registered;second conversion method ignored.|
>
> Is there a way to avoid this warning?
>

Why do you need the explicit converter if you also define a
class_<range_t> ? Wouldn't everything work just fine without it ?

        Stefan

-- 

      ...ich hab' noch einen Koffer in Berlin...



More information about the Cplusplus-sig mailing list