From 4a30d7f34efd30f21b560dbd3442a86482615b07 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 27 Oct 2024 15:47:35 +0000 Subject: Add stream support for tuples --- lib/stream_support.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/stream_support.h b/lib/stream_support.h index 57d82a1..d71356c 100644 --- a/lib/stream_support.h +++ b/lib/stream_support.h @@ -6,6 +6,7 @@ #include #include #include +#include #include template @@ -49,6 +50,22 @@ namespace std { return (s << '(' << v.first << ", " << v.second << ')'); } + namespace { + template + std::ostream & + printTuple(std::ostream & s, const std::tuple & v, std::integer_sequence) + { + return ((s << (Idx ? ", " : "") << std::get(v)), ...); + } + } + + template + std::ostream & + operator<<(std::ostream & s, const std::tuple & v) + { + return printTuple(s << '{', v, std::make_index_sequence()) << '}'; + } + inline std::ostream & operator<<(std::ostream & s, const Arc & arc) { -- cgit v1.2.3