From b6880795627bc2f40a558c54af362df5dfc12b78 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 29 Oct 2024 00:32:44 +0000 Subject: Update operator<< for collections to work with ranges --- lib/stream_support.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/stream_support.h b/lib/stream_support.h index d71356c..423c7d4 100644 --- a/lib/stream_support.h +++ b/lib/stream_support.h @@ -17,14 +17,14 @@ concept NonStringIterableCollection namespace std { std::ostream & - operator<<(std::ostream & s, const NonStringIterableCollection auto & v) + operator<<(std::ostream & s, const NonStringIterableCollection auto & collection) { s << '('; - for (const auto & i : v) { - if (&i != &*v.begin()) { + for (size_t nth {}; const auto & element : collection) { + if (nth++) { s << ", "; } - s << i; + s << element; } return s << ')'; } -- cgit v1.2.3