Skip to content
Snippets Groups Projects
Commit 46840956 authored by Wilson Jallet's avatar Wilson Jallet :clapper:
Browse files

[unittest] Test returning reference of std::pair

parent 694d996a
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ...@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added ### Added
- Add test returning reference of std::pair ([#503](https://github.com/stack-of-tasks/eigenpy/pull/503))
- Add more general visitor `GenericMapPythonVisitor` for map types test `boost::unordered_map<std::string, int>` ([#504](https://github.com/stack-of-tasks/eigenpy/pull/504)) - Add more general visitor `GenericMapPythonVisitor` for map types test `boost::unordered_map<std::string, int>` ([#504](https://github.com/stack-of-tasks/eigenpy/pull/504))
- Support for non-[default-contructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible) types in map types ([#504](https://github.com/stack-of-tasks/eigenpy/pull/504)) - Support for non-[default-contructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible) types in map types ([#504](https://github.com/stack-of-tasks/eigenpy/pull/504))
- Add type_info helpers ([#502](https://github.com/stack-of-tasks/eigenpy/pull/502)) - Add type_info helpers ([#502](https://github.com/stack-of-tasks/eigenpy/pull/502))
......
from std_pair import copy, std_pair_to_tuple from std_pair import copy, passthrough, std_pair_to_tuple
t = (1, 2.0) t = (1, 2.0)
assert std_pair_to_tuple(t) == t assert std_pair_to_tuple(t) == t
assert copy(t) == t assert copy(t) == t
assert passthrough(t) == t
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include <eigenpy/eigenpy.hpp> #include <eigenpy/eigenpy.hpp>
#include <eigenpy/std-pair.hpp> #include <eigenpy/std-pair.hpp>
#include <iostream>
namespace bp = boost::python; namespace bp = boost::python;
...@@ -17,6 +16,11 @@ std::pair<T1, T2> copy(const std::pair<T1, T2>& pair) { ...@@ -17,6 +16,11 @@ std::pair<T1, T2> copy(const std::pair<T1, T2>& pair) {
return 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) { BOOST_PYTHON_MODULE(std_pair) {
eigenpy::enableEigenPy(); eigenpy::enableEigenPy();
...@@ -25,4 +29,6 @@ BOOST_PYTHON_MODULE(std_pair) { ...@@ -25,4 +29,6 @@ BOOST_PYTHON_MODULE(std_pair) {
bp::def("std_pair_to_tuple", std_pair_to_tuple<int, double>); bp::def("std_pair_to_tuple", std_pair_to_tuple<int, double>);
bp::def("copy", copy<int, double>); bp::def("copy", copy<int, double>);
bp::def("passthrough", passthrough<int, double>,
bp::return_value_policy<bp::copy_const_reference>());
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment