From e26165cea9d06029784aa25f1fcfafdf66b8460f Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 19 Nov 2018 15:35:56 +1100 Subject: [PATCH] algo/search: return the score and the object in `minimises` --- algo/search.hpp | 2 +- test/algo/search.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/algo/search.hpp b/algo/search.hpp index 0fa79463..1d3320f4 100644 --- a/algo/search.hpp +++ b/algo/search.hpp @@ -61,6 +61,6 @@ namespace cruft::search { } } - return best_item; + return std::pair (std::move (best_score), std::move (best_item)); } } \ No newline at end of file diff --git a/test/algo/search.cpp b/test/algo/search.cpp index e8ef3bbf..2a8e3a84 100644 --- a/test/algo/search.cpp +++ b/test/algo/search.cpp @@ -30,14 +30,14 @@ main (void) }; - auto best = cruft::search::minimises ( + auto const [best_score, best_iterator] = cruft::search::minimises ( std::begin (src), std::end (src), [] (auto const a, auto const b) { return cruft::distance2 (a, b); }, dst ); - tap.expect_eq (best, src + 2, "minimises point3 using distance2"); + tap.expect_eq (best_iterator, src + 2, "minimises point3 using distance2"); }