File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -42,9 +42,10 @@ BOOST_AUTO_TEST_CASE(nav_get_location) {
4242}
4343
4444// weak backport of std::transform.
45- template <typename T, typename U>
46- std::vector<T> mapOver (const std::vector<U>& source, T (*f)(const U&)) {
47- std::vector<T> ret;
45+ template <typename T, typename Func>
46+ auto mapOver (const std::vector<T>& source, Func f) {
47+ using Result = decltype (f (source.front ()));
48+ std::vector<Result> ret;
4849 for (const auto & x : source) {
4950 ret.push_back (f (x));
5051 }
@@ -71,11 +72,8 @@ BOOST_AUTO_TEST_CASE(nav_waypoints) {
7172 const std::vector<std::string> expected_ids = {(*waypoints)[0 ].id , (*waypoints)[2 ].id };
7273 waypoints = client.get_waypoints ();
7374 BOOST_CHECK_EQUAL (waypoints->size (), 2 );
74- const auto actual_ids = mapOver (
75- *waypoints,
76- (std::string (*)(const Navigation::Waypoint&))[](const Navigation::Waypoint& wp) {
77- return wp.id ;
78- });
75+ const auto actual_ids =
76+ mapOver (*waypoints, [](const Navigation::Waypoint& wp) { return wp.id ; });
7977 BOOST_CHECK_EQUAL (expected_ids, actual_ids);
8078 });
8179}
You can’t perform that action at this time.
0 commit comments