From 421ae75fa94a05b71c03255af4ad597a60fc8ed9 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 8 Mar 2024 01:17:11 +0000 Subject: Rework stream support to work with any collection --- lib/stream_support.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/stream_support.h b/lib/stream_support.h index fa536f1..57d82a1 100644 --- a/lib/stream_support.h +++ b/lib/stream_support.h @@ -11,17 +11,16 @@ template concept stringlike = requires(const S & s) { s.substr(0); }; template -concept spanable = std::is_constructible_v, T> && !stringlike - && !std::is_same_v, T>; +concept NonStringIterableCollection + = std::is_same_v().begin()), decltype(std::declval().end())> && !stringlike; namespace std { - template std::ostream & - operator<<(std::ostream & s, const span v) + operator<<(std::ostream & s, const NonStringIterableCollection auto & v) { s << '('; for (const auto & i : v) { - if (&i != &v.front()) { + if (&i != &*v.begin()) { s << ", "; } s << i; @@ -43,13 +42,6 @@ namespace std { return (s << std::span {&v[0], L}); } - template - std::ostream & - operator<<(std::ostream & s, const T & v) - { - return (s << std::span {v}); - } - template std::ostream & operator<<(std::ostream & s, const std::pair & v) -- cgit v1.2.3