-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathstd_pair.cpp
34 lines (26 loc) · 910 Bytes
/
std_pair.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/// @file
/// @copyright Copyright 2023 CNRS INRIA
#include <eigenpy/eigenpy.hpp>
#include <eigenpy/std-pair.hpp>
namespace bp = boost::python;
template <typename T1, typename T2>
bp::tuple std_pair_to_tuple(const std::pair<T1, T2>& pair) {
return bp::make_tuple(pair.first, pair.second);
}
template <typename T1, typename T2>
std::pair<T1, T2> copy(const std::pair<T1, T2>& pair) {
return pair;
}
template <typename T1, typename T2>
const std::pair<T1, T2>& passthrough(const std::pair<T1, T2>& pair) {
return pair;
}
BOOST_PYTHON_MODULE(std_pair) {
eigenpy::enableEigenPy();
typedef std::pair<int, double> PairType;
eigenpy::StdPairConverter<PairType>::registration();
bp::def("std_pair_to_tuple", std_pair_to_tuple<int, double>);
bp::def("copy", copy<int, double>);
bp::def("passthrough", passthrough<int, double>,
bp::return_value_policy<bp::copy_const_reference>());
}