mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2024-11-12 21:09:01 +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 detail {
|
||||
template<typename InputIterator, typename Compare>
|
||||
inline SPROUT_CONSTEXPR InputIterator
|
||||
iter_max(InputIterator a, InputIterator b, Compare comp) {
|
||||
template<typename ForwardIterator, typename Compare>
|
||||
inline SPROUT_CONSTEXPR ForwardIterator
|
||||
iter_max(ForwardIterator a, ForwardIterator b, Compare comp) {
|
||||
return comp(*a, *b) ? b : a;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,20 +19,20 @@
|
|||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
template<typename InputIteratorPair, typename Compare>
|
||||
inline SPROUT_CONSTEXPR InputIteratorPair
|
||||
iter_minmax_pair(InputIteratorPair const& a, InputIteratorPair const& b, Compare comp) {
|
||||
return InputIteratorPair(
|
||||
template<typename ForwardIteratorPair, typename Compare>
|
||||
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<typename InputIteratorPair, typename InputIterator, typename Compare>
|
||||
inline SPROUT_CONSTEXPR InputIteratorPair
|
||||
iter_minmax(InputIteratorPair const& a, InputIterator b, Compare comp) {
|
||||
return InputIteratorPair(
|
||||
template<typename ForwardIteratorPair, typename ForwardIterator, typename Compare>
|
||||
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)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue