.. _program_listing_file__tmp_ws_src_eigenpy_include_eigenpy_std-pair.hpp: Program Listing for File std-pair.hpp ===================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/eigenpy/include/eigenpy/std-pair.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // // Copyright (c) 2023 INRIA // #ifndef __eigenpy_utils_std_pair_hpp__ #define __eigenpy_utils_std_pair_hpp__ #include #include namespace eigenpy { template struct StdPairConverter { typedef typename pair_type::first_type T1; typedef typename pair_type::second_type T2; static PyObject* convert(const pair_type& pair) { return boost::python::incref( boost::python::make_tuple(pair.first, pair.second).ptr()); } static void* convertible(PyObject* obj) { if (!PyTuple_CheckExact(obj)) return 0; if (PyTuple_Size(obj) != 2) return 0; { boost::python::tuple tuple(boost::python::borrowed(obj)); boost::python::extract elt1(tuple[0]); if (!elt1.check()) return 0; boost::python::extract elt2(tuple[1]); if (!elt2.check()) return 0; } return obj; } static void construct( PyObject* obj, boost::python::converter::rvalue_from_python_stage1_data* memory) { boost::python::tuple tuple(boost::python::borrowed(obj)); void* storage = reinterpret_cast< boost::python::converter::rvalue_from_python_storage*>( reinterpret_cast(memory)) ->storage.bytes; new (storage) pair_type(boost::python::extract(tuple[0]), boost::python::extract(tuple[1])); memory->convertible = storage; } static PyTypeObject const* get_pytype() { PyTypeObject const* py_type = &PyTuple_Type; return py_type; } static void registration() { boost::python::converter::registry::push_back( &convertible, &construct, boost::python::type_id() #ifndef BOOST_PYTHON_NO_PY_SIGNATURES , get_pytype #endif ); boost::python::to_python_converter(); } }; } // namespace eigenpy #endif // ifndef __eigenpy_utils_std_pair_hpp__