6 #ifndef __eigenpy_utils_map_hpp__ 7 #define __eigenpy_utils_map_hpp__ 9 #include <boost/python/suite/indexing/map_indexing_suite.hpp> 13 template <
typename Container>
15 :
public boost::python::def_visitor<
16 overload_base_get_item_for_std_map<Container> > {
18 typedef typename Container::value_type::second_type
data_type;
22 template <
class Class>
29 boost::python::back_reference<Container&> container, PyObject* i_) {
31 typename Container::iterator i = container.get().find(idx);
32 if (i == container.get().end()) {
33 PyErr_SetString(PyExc_KeyError,
"Invalid key");
34 bp::throw_error_already_set();
37 typename bp::to_python_indirect<data_type&,
38 bp::detail::make_reference_holder>
40 return bp::object(bp::handle<>(convert(i->second)));
44 bp::extract<key_type const&> i(i_);
48 bp::extract<key_type> i(i_);
49 if (i.check())
return i();
52 PyErr_SetString(PyExc_TypeError,
"Invalid index type");
53 bp::throw_error_already_set();
61 #endif // ifndef __eigenpy_utils_map_hpp__ Container::value_type value_type
void visit(Class &cl) const
Container::value_type::second_type data_type
static boost::python::object base_get_item(boost::python::back_reference< Container &> container, PyObject *i_)
Container::key_type index_type
static index_type convert_index(Container &, PyObject *i_)
Container::key_type key_type