I substituted the convert method in pair_to_tuple with the following static PyObject* convert(ctype const& v) { using namespace boost::python; list values; values.append(v.first); values.append(v.second); return incref(tuple(values).ptr()); }
And this works in all situations. However, I admit it is not a great solution. 2008/12/11 Luca Sbardella <luca.sbarde...@gmail.com> > My authomatic conversion function from std::pair does not work when one of > the pair type is a boost::python::object. > > Template for conversion > > template<class K, class T> > struct pair_to_tuple { > typedef pair_to_tuple<K,T> converter; > typedef std::pair<K,T> ctype; > > static PyObject* convert(ctype const& v) { > using namespace boost::python; > return incref(make_tuple(v.first,v.second).ptr()); > } > static void register_to_python() { > boost::python::to_python_converter<ctype,converter>(); > } > }; > > > > > using namespace boost::python; > pair_to_tuple<double,object>::register_to_python(); <--------- > FAILED > pair_to_tuple<double,std::string>::register_to_python(); <--------- OK > > The error I get is > *error C2668: 'boost::python::make_tuple' : ambiguous call to overloaded > function > could be 'boost::python::tuple boost::python::make_tuple<_Ty1,_Ty2>(const > A0 &,const A1 &)'** > or 'boost::tuples::tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> > boost::tuples::make_tuple<_Ty1,_Ty2>(const T0 &,const T1 &)' [found using > argument-dependent lookup] > * > What I'm I doing wrong?* > *
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig