From 17942dd51f0e9844dc58198036fb2d72998c00b7 Mon Sep 17 00:00:00 2001 From: subcrip Date: Sat, 18 May 2024 19:38:06 +0800 Subject: [PATCH] Update include.hh Signed-off-by: subcrip --- include.hh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include.hh b/include.hh index 2e23ee5..bba30f3 100644 --- a/include.hh +++ b/include.hh @@ -429,7 +429,7 @@ vector> zip(Iterator_T a_first, Iterator_T a_last, Iterator_U b_first vector> res; auto a_it = a_first; auto b_it = b_first; - for (; a_it != a_last and b_it != b_last; ++a_it, ++b_it) { + for (; not (a_it == a_last) and not (b_it == b_last); ++a_it, ++b_it) { res.emplace_back(*a_it, *b_it); } return res; @@ -459,4 +459,7 @@ public: ArithmeticIterator& operator--() { --value; return *this; } bool operator==(const ArithmeticIterator& rhs) const { return value == rhs.value; } }; +template vector> enumerate(const vector& container) { + return zip(ArithmeticIterator(0), ArithmeticIterator(INT_MAX), container.begin(), container.end()); +} /////////////////////////////////////////////////////////