On 28 August 2015 at 13:41, Stefan Seefeld <ste...@seefeld.name> wrote:
> 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 > This is in too separate modules. The converter is registered in module1, and the class_<range_t> in module 2. I import 1 then 2, then it happens Also the intents are different. THe pair<string,string> is to be considered as a (str1,str2) tuple of 2 values. The pair<string*, string*> is the [begin, end[ iterators into an array with value_type string
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org https://mail.python.org/mailman/listinfo/cplusplus-sig