From ea13b6d5ea2aab7bdbe90f9e4f0085b007d68b99 Mon Sep 17 00:00:00 2001 From: subcrip Date: Mon, 13 May 2024 15:14:55 +0800 Subject: [PATCH] Update include.hh Signed-off-by: subcrip --- include.hh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include.hh b/include.hh index 5fba3dc..2bb20c2 100644 --- a/include.hh +++ b/include.hh @@ -409,10 +409,11 @@ vector> zip(Iterator_T a_first, Iterator_T a_last, Iterator_U b_first template vector> zip_n(Iterator_T a_first, Iterator_U b_first, size_t n) { vector> res; - auto a_it = a_first; - auto b_it = b_first; - for (; n != 0; ++a_it, ++b_it, --n) { - res.emplace_back(*a_it, *b_it); + if (n > 0) { + res.emplace_back(*a_first, *b_first); + for (size_t i = 1; i != n; ++i) { + res.emplace_back(*++a_first, *++b_first); + } } return res; }