5 #ifndef COAL_PYTHON_UTILS_STD_PAIR_H 
    6 #define COAL_PYTHON_UTILS_STD_PAIR_H 
    8 #include <boost/python.hpp> 
   11 template <
typename pair_type>
 
   13   typedef typename pair_type::first_type 
T1;
 
   14   typedef typename pair_type::second_type 
T2;
 
   16   static PyObject* 
convert(
const pair_type& pair) {
 
   17     return boost::python::incref(
 
   18         boost::python::make_tuple(pair.first, pair.second).ptr());
 
   22     if (!PyTuple_CheckExact(obj)) 
return 0;
 
   23     if (PyTuple_Size(obj) != 2) 
return 0;
 
   25       boost::python::tuple tuple(boost::python::borrowed(obj));
 
   26       boost::python::extract<T1> elt1(tuple[0]);
 
   27       if (!elt1.check()) 
return 0;
 
   28       boost::python::extract<T2> elt2(tuple[1]);
 
   29       if (!elt2.check()) 
return 0;
 
   36       boost::python::converter::rvalue_from_python_stage1_data* memory) {
 
   37     boost::python::tuple tuple(boost::python::borrowed(obj));
 
   40             boost::python::converter::rvalue_from_python_storage<pair_type>*
>(
 
   41             reinterpret_cast<void*
>(memory))
 
   43     new (storage) pair_type(boost::python::extract<T1>(tuple[0]),
 
   44                             boost::python::extract<T2>(tuple[1]));
 
   45     memory->convertible = storage;
 
   49     PyTypeObject 
const* py_type = &PyTuple_Type;
 
   54     boost::python::converter::registry::push_back(
 
   56         boost::python::type_id<pair_type>()
 
   57 #ifndef BOOST_PYTHON_NO_PY_SIGNATURES
 
   65 #endif  // ifndef COAL_PYTHON_UTILS_STD_PAIR_H