From 6833b85e2ba6849bb7a7f1825729075fabf22d0a Mon Sep 17 00:00:00 2001 From: Mitsuru Kariya Date: Mon, 26 Aug 2013 12:08:35 +0900 Subject: [PATCH] fix minmax_element --- sprout/algorithm/max_element.hpp | 6 +++--- sprout/algorithm/minmax_element.hpp | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sprout/algorithm/max_element.hpp b/sprout/algorithm/max_element.hpp index 74eb108e..e6f2534e 100644 --- a/sprout/algorithm/max_element.hpp +++ b/sprout/algorithm/max_element.hpp @@ -18,9 +18,9 @@ namespace sprout { namespace detail { - template - inline SPROUT_CONSTEXPR InputIterator - iter_max(InputIterator a, InputIterator b, Compare comp) { + template + inline SPROUT_CONSTEXPR ForwardIterator + iter_max(ForwardIterator a, ForwardIterator b, Compare comp) { return comp(*a, *b) ? b : a; } diff --git a/sprout/algorithm/minmax_element.hpp b/sprout/algorithm/minmax_element.hpp index a684b917..9bba8516 100644 --- a/sprout/algorithm/minmax_element.hpp +++ b/sprout/algorithm/minmax_element.hpp @@ -19,20 +19,20 @@ namespace sprout { namespace detail { - template - inline SPROUT_CONSTEXPR InputIteratorPair - iter_minmax_pair(InputIteratorPair const& a, InputIteratorPair const& b, Compare comp) { - return InputIteratorPair( + template + inline SPROUT_CONSTEXPR ForwardIteratorPair + iter_minmax_pair(ForwardIteratorPair const& a, ForwardIteratorPair const& b, Compare comp) { + return ForwardIteratorPair( comp(*sprout::first(b), *sprout::first(a)) ? sprout::first(b) : sprout::first(a), - comp(*sprout::second(a), *sprout::second(b)) ? sprout::second(b) : sprout::second(a) + comp(*sprout::second(b), *sprout::second(a)) ? sprout::second(a) : sprout::second(b) ); } - template - inline SPROUT_CONSTEXPR InputIteratorPair - iter_minmax(InputIteratorPair const& a, InputIterator b, Compare comp) { - return InputIteratorPair( + template + inline SPROUT_CONSTEXPR ForwardIteratorPair + iter_minmax(ForwardIteratorPair const& a, ForwardIterator b, Compare comp) { + return ForwardIteratorPair( comp(*b, *sprout::first(a)) ? b : sprout::first(a), - comp(*sprout::second(a), *b) ? b : sprout::second(a) + comp(*sprout::second(b), *a) ? a : sprout::second(b) ); }