[C++-sig] conversion problem

Luca Sbardella luca.sbardella at gmail.com
Thu Dec 11 16:29:34 CET 2008


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?*
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20081211/2c5bd61a/attachment.htm>


More information about the Cplusplus-sig mailing list