From 65c05e810f4385fdb6a058d65e1785cef07ad35c Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Fri, 16 Jun 2023 11:58:37 -0400 Subject: [PATCH] include/types: Add `operator <<` for `std::span` Signed-off-by: Adam C. Emerson --- src/include/types.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/include/types.h b/src/include/types.h index bedc939a508..c5754528bce 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -38,6 +38,7 @@ extern "C" { #include #include #include +#include #include #include #include "boost/tuple/tuple.hpp" @@ -84,6 +85,8 @@ template inline std::ostream& operator<<(std::ostream&out, const std::pair& v); template inline std::ostream& operator<<(std::ostream& out, const std::vector& v); +template +inline std::ostream& operator<<(std::ostream& out, const std::span& s); template inline std::ostream& operator<<(std::ostream& out, const boost::container::small_vector& v); template @@ -137,6 +140,19 @@ inline std::ostream& operator<<(std::ostream& out, const std::vector& v return out; } +template +inline std::ostream& operator<<(std::ostream& out, const std::span& s) { + bool first = true; + out << "["; + for (const auto& p : s) { + if (!first) out << ","; + out << p; + first = false; + } + out << "]"; + return out; +} + template inline std::ostream& operator<<(std::ostream& out, const boost::container::small_vector& v) { bool first = true; -- 2.39.5