From be3037dbc8b2137af0d49642f558803ae4806cc7 Mon Sep 17 00:00:00 2001 From: Nils Wentzell Date: Tue, 1 Feb 2022 16:23:51 -0500 Subject: [PATCH] Add comment to itertools::distance implementation --- c++/itertools/itertools.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/c++/itertools/itertools.hpp b/c++/itertools/itertools.hpp index 997764b..4786279 100644 --- a/c++/itertools/itertools.hpp +++ b/c++/itertools/itertools.hpp @@ -67,6 +67,7 @@ namespace itertools { template inline typename std::iterator_traits::difference_type distance(Iter first, EndIter last) { if constexpr (std::is_same_v::iterator_category, std::random_access_iterator_tag>) { + // Difference should be defined also for the the case that last is a sentinel return last - first; } else { typename std::iterator_traits::difference_type r(0);