aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include/algorithm
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2015-02-11 15:41:34 +0000
committerMarshall Clow <mclow.lists@gmail.com>2015-02-11 15:41:34 +0000
commit002144f61dfdb96cbb75136b2d99b7d2391177d1 (patch)
tree98d4199538d253700e7d1bae018bda520382e381 /libcxx/include/algorithm
parent8a8b00b684175dc329ade9fda0f9c454d82278d2 (diff)
downloadllvm-002144f61dfdb96cbb75136b2d99b7d2391177d1.zip
llvm-002144f61dfdb96cbb75136b2d99b7d2391177d1.tar.gz
llvm-002144f61dfdb96cbb75136b2d99b7d2391177d1.tar.bz2
Fix PR 22541: When values are equal, minmax should return the rightmost one in the initializer_list
llvm-svn: 228839
Diffstat (limited to 'libcxx/include/algorithm')
-rw-r--r--libcxx/include/algorithm12
1 files changed, 6 insertions, 6 deletions
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 475ba66..415059d 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -2771,7 +2771,7 @@ minmax(initializer_list<_Tp> __t, _Compare __comp)
typedef typename initializer_list<_Tp>::const_iterator _Iter;
_Iter __first = __t.begin();
_Iter __last = __t.end();
- std::pair<_Tp, _Tp> __result ( *__first, *__first );
+ std::pair<_Tp, _Tp> __result(*__first, *__first);
++__first;
if (__t.size() % 2 == 0)
@@ -2786,13 +2786,13 @@ minmax(initializer_list<_Tp> __t, _Compare __comp)
while (__first != __last)
{
_Tp __prev = *__first++;
- if (__comp(__prev, *__first)) {
- if (__comp(__prev, __result.first)) __result.first = __prev;
- if (__comp(__result.second, *__first)) __result.second = *__first;
+ if (__comp(*__first, __prev)) {
+ if ( __comp(*__first, __result.first)) __result.first = *__first;
+ if (!__comp(__prev, __result.second)) __result.second = __prev;
}
else {
- if (__comp(*__first, __result.first)) __result.first = *__first;
- if (__comp(__result.second, __prev)) __result.second = __prev;
+ if ( __comp(__prev, __result.first)) __result.first = __prev;
+ if (!__comp(*__first, __result.second)) __result.second = *__first;
}
__first++;