@@ -70,8 +70,6 @@ struct overload_base_get_item_for_std_map
7070// Rohan Budhiraja.
7171// /////////////////////////////////////////////////////////////////////////////
7272
73- namespace python {
74-
7573namespace bp = boost::python;
7674
7775/* *
@@ -162,39 +160,50 @@ struct dict_to_map {
162160};
163161
164162/* *
165- * @brief Expose an std:: map from a type given as template argument .
163+ * @brief Expose the map-like container, e.g. (std::map) .
166164 *
167- * @param[in] T Type to expose as std::map<T>.
168- * @param[in] Compare Type for the Compare in std::map<T,Compare,Allocator>.
169- * @param[in] Allocator Type for the Allocator in
170- * std::map<T,Compare,Allocator>.
165+ * @param[in] Container Container to expose.
171166 * @param[in] NoProxy When set to false, the elements will be copied when
172167 * returned to Python.
173168 */
174- template <class Key , class T , class Compare = std::less<Key>,
175- class Allocator = std::allocator<std::pair<const Key, T> >,
176- bool NoProxy = false >
177- struct StdMapPythonVisitor
178- : public bp::map_indexing_suite<
179- typename std::map<Key, T, Compare, Allocator>, NoProxy>,
180- public dict_to_map<std::map<Key, T, Compare, Allocator> > {
181- typedef std::map<Key, T, Compare, Allocator> Container;
169+ template <class Container , bool NoProxy = false >
170+ struct GenericMapVisitor : public bp ::map_indexing_suite<Container, NoProxy>,
171+ public dict_to_map<Container> {
182172 typedef dict_to_map<Container> FromPythonDictConverter;
183173
184174 static void expose (const std::string& class_name,
185175 const std::string& doc_string = " " ) {
186176 namespace bp = bp;
187177
188178 bp::class_<Container>(class_name.c_str (), doc_string.c_str ())
189- .def (StdMapPythonVisitor ())
179+ .def (GenericMapVisitor ())
190180 .def (" todict" , &FromPythonDictConverter::todict, bp::arg (" self" ),
191- " Returns the std:: map as a Python dictionary." )
181+ " Returns the map type as a Python dictionary." )
192182 .def_pickle (PickleMap<Container>());
193183 // Register conversion
194184 FromPythonDictConverter::register_converter ();
195185 }
196186};
197187
188+ /* *
189+ * @brief Expose an std::map from a type given as template argument.
190+ *
191+ * @param[in] T Type to expose as std::map<T>.
192+ * @param[in] Compare Type for the Compare in std::map<T,Compare,Allocator>.
193+ * @param[in] Allocator Type for the Allocator in
194+ * std::map<T,Compare,Allocator>.
195+ * @param[in] NoProxy When set to false, the elements will be copied when
196+ * returned to Python.
197+ */
198+ template <class Key , class T , class Compare = std::less<Key>,
199+ class Allocator = std::allocator<std::pair<const Key, T> >,
200+ bool NoProxy = false >
201+ struct StdMapPythonVisitor
202+ : GenericMapVisitor<std::map<Key, T, Compare, Allocator>, NoProxy> {};
203+
204+ namespace python {
205+ // fix previous mistake
206+ using ::eigenpy::StdMapPythonVisitor;
198207} // namespace python
199208} // namespace eigenpy
200209
0 commit comments