From 7e47349b3001c74fe94f92e1af75b5d90cb65185 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 4 Oct 2018 16:53:00 +0200 Subject: [PATCH] Ref T386, partial sort --- src/blackmisc/sequence.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blackmisc/sequence.h b/src/blackmisc/sequence.h index 8e094b15a..4e2d9bb48 100644 --- a/src/blackmisc/sequence.h +++ b/src/blackmisc/sequence.h @@ -462,7 +462,7 @@ namespace BlackMisc //! In-place move the smallest n elements to the beginning and sort them. template void partiallySort(size_type n, Predicate p) { - std::partial_sort(begin(), begin() + n, end(), p); + std::partial_sort(begin(), begin() + std::min(n, size()), end(), p); } //! In-place partially sort by some particular key(s).