From bf3e9eabd561003880e985553bcd309a115524d2 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 7 Dec 2023 22:25:54 +0200 Subject: [PATCH] BAN: Implement distance() for iterators --- BAN/include/BAN/Iterators.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/BAN/include/BAN/Iterators.h b/BAN/include/BAN/Iterators.h index 36af28bfd6..003c578428 100644 --- a/BAN/include/BAN/Iterators.h +++ b/BAN/include/BAN/Iterators.h @@ -36,6 +36,25 @@ namespace BAN return it - count; } + template + size_t distance(It it1, It it2) + { + size_t dist = 0; + while (it1 != it2) + { + ++it1; + ++dist; + } + return dist; + } + + template + requires requires(It it1, It it2) { requires is_integral_v; } + size_t distance(It it1, It it2) + { + return it2 - it1; + } + template class IteratorSimpleGeneral {