std_map.cpp
Go to the documentation of this file.
1 
4 #include <eigenpy/eigenpy.hpp>
5 #include <eigenpy/std-map.hpp>
6 #include <boost/unordered_map.hpp>
7 
8 namespace bp = boost::python;
9 
10 template <typename T1>
11 bp::dict std_map_to_dict(const std::map<std::string, T1>& map) {
12  bp::dict dictionnary;
13  for (auto const& x : map) {
14  dictionnary[x.first] = x.second;
15  }
16  return dictionnary;
17 }
18 
19 template <typename T1>
20 std::map<std::string, T1> copy(const std::map<std::string, T1>& map) {
21  std::map<std::string, T1> out = map;
22  return out;
23 }
24 
25 template <typename T1>
26 boost::unordered_map<std::string, T1> copy_boost(
27  const boost::unordered_map<std::string, T1>& obj) {
28  return obj;
29 }
30 
31 struct X {
32  X() = delete;
33  X(int x) : val(x) {}
34  int val;
35 };
36 
39 
41  std::string, double, std::less<std::string>,
42  std::allocator<std::pair<const std::string, double> >,
43  true>::expose("StdMap_Double");
44 
46  "boost_map_int");
47 
49 
50  bp::def("std_map_to_dict", std_map_to_dict<double>);
51  bp::def("copy", copy<double>);
52  bp::def("copy_boost", copy_boost<int>);
53 }
boost::python
Definition: alignment.hpp:49
eigenpy::enableEigenPy
void EIGENPY_DLLAPI enableEigenPy()
Definition: eigenpy.cpp:43
BOOST_PYTHON_MODULE
BOOST_PYTHON_MODULE(std_map)
Definition: std_map.cpp:37
std_map_to_dict
bp::dict std_map_to_dict(const std::map< std::string, T1 > &map)
Definition: std_map.cpp:11
copy_boost
boost::unordered_map< std::string, T1 > copy_boost(const boost::unordered_map< std::string, T1 > &obj)
Definition: std_map.cpp:26
copy
std::map< std::string, T1 > copy(const std::map< std::string, T1 > &map)
Definition: std_map.cpp:20
test_user_struct.x
x
Definition: test_user_struct.py:4
eigenpy::expose
void expose()
Call the expose function of a given type T.
Definition: expose.hpp:23
eigenpy.hpp
eigenpy::GenericMapVisitor
Expose the map-like container, e.g. (std::map).
Definition: std-map.hpp:209
std-map.hpp
X::X
X(int x)
Definition: std_map.cpp:33
X::val
int val
Definition: std_map.cpp:34
eigenpy::StdMapPythonVisitor
Expose an std::map from a type given as template argument.
Definition: std-map.hpp:241
X::X
X()
Definition: multiple_registration.cpp:8
X
Definition: deprecation_policy.cpp:19


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Fri Sep 20 2024 02:17:48