Fix PR# 38900 - don't call swap inside of random_shuffle when we'd be swapping an element with itself
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@341975 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2987,7 +2987,8 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
|
||||
for (--__last; __first < __last; ++__first, --__d)
|
||||
{
|
||||
difference_type __i = __rand(__d);
|
||||
swap(*__first, *(__first + __i));
|
||||
if (__i != difference_type(0))
|
||||
swap(*__first, *(__first + __i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user