mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
Merge pull request #22 from kariya-mitsuru/minmax
[algorithm.minmax_element] fix minmax_element(max part) etc.
This commit is contained in:
commit
15e0303f06
2 changed files with 13 additions and 13 deletions
|
@ -18,9 +18,9 @@
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename InputIterator, typename Compare>
|
template<typename ForwardIterator, typename Compare>
|
||||||
inline SPROUT_CONSTEXPR InputIterator
|
inline SPROUT_CONSTEXPR ForwardIterator
|
||||||
iter_max(InputIterator a, InputIterator b, Compare comp) {
|
iter_max(ForwardIterator a, ForwardIterator b, Compare comp) {
|
||||||
return comp(*a, *b) ? b : a;
|
return comp(*a, *b) ? b : a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,20 +19,20 @@
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename InputIteratorPair, typename Compare>
|
template<typename ForwardIteratorPair, typename Compare>
|
||||||
inline SPROUT_CONSTEXPR InputIteratorPair
|
inline SPROUT_CONSTEXPR ForwardIteratorPair
|
||||||
iter_minmax_pair(InputIteratorPair const& a, InputIteratorPair const& b, Compare comp) {
|
iter_minmax_pair(ForwardIteratorPair const& a, ForwardIteratorPair const& b, Compare comp) {
|
||||||
return InputIteratorPair(
|
return ForwardIteratorPair(
|
||||||
comp(*sprout::first(b), *sprout::first(a)) ? sprout::first(b) : sprout::first(a),
|
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<typename InputIteratorPair, typename InputIterator, typename Compare>
|
template<typename ForwardIteratorPair, typename ForwardIterator, typename Compare>
|
||||||
inline SPROUT_CONSTEXPR InputIteratorPair
|
inline SPROUT_CONSTEXPR ForwardIteratorPair
|
||||||
iter_minmax(InputIteratorPair const& a, InputIterator b, Compare comp) {
|
iter_minmax(ForwardIteratorPair const& a, ForwardIterator b, Compare comp) {
|
||||||
return InputIteratorPair(
|
return ForwardIteratorPair(
|
||||||
comp(*b, *sprout::first(a)) ? b : sprout::first(a),
|
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)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue