On 28 August 2015 at 15:01, Stefan Seefeld <ste...@seefeld.name> wrote:
> On 28/08/15 09:26 AM, MM wrote: > > 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 > > > Oups, sorry, I hadn't noticed that they had different types. Can you > please post a minimal bug self-contained test case ? I'd like to debug > this a bit to better understand what is going on. I believe this should > work as there is no reason the two types should be confused. (It > obviously depends on your "Converter" type, which you haven't shown.) > > Thanks, > Stefan > > Well, there's something about the fact that pointer types somehow change to the types pointed to.... I don't understand it well I tried to strip it down here: /// header file template <typename T1, typename T2> struct stdpair_to_python_tuple { static PyObject* convert(const std::pair<T1,T2>&pr) { return incref( make_tuple(pr.first, pr.second).ptr() ); } }; /// module1.cpp BOOST_PYTHON_MODULE(libmodule1) { to_python_converter< std::pair<std::string, std::string>, stdpair_to_python_tuple<std::string,std::string>>(); } /// module2.cpp typedef std::pair<const std::string*,const std::string*> range_t; range_t range; BOOST_PYTHON_MODULE(libmodule2) { using namespace boost::python; class_<range_t>("range") .def("__iter__", range(&range_t::first, &range_t::second)) ; scope().attr("allitems") = object(ptr(&range)); } Load 1 then 2 it should trigger the warning. Apologies for missing the includes. Thanks
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org https://mail.python.org/mailman/listinfo/cplusplus-sig