]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
include/types: Add `operator <<` for `std::span`
authorAdam C. Emerson <aemerson@redhat.com>
Fri, 16 Jun 2023 15:58:37 +0000 (11:58 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Tue, 1 Apr 2025 15:10:12 +0000 (11:10 -0400)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/include/types.h

index bedc939a50889fc983821bfbd2ea2503aceee803..c5754528bced42989d2f41461d40fd42d654ab67 100644 (file)
@@ -38,6 +38,7 @@ extern "C" {
 #include <string>
 #include <list>
 #include <set>
+#include <span>
 #include <boost/container/flat_set.hpp>
 #include <boost/container/flat_map.hpp>
 #include "boost/tuple/tuple.hpp"
@@ -84,6 +85,8 @@ template<class A, class B>
 inline std::ostream& operator<<(std::ostream&out, const std::pair<A,B>& v);
 template<class A, class Alloc>
 inline std::ostream& operator<<(std::ostream& out, const std::vector<A,Alloc>& v);
+template<class T, std::size_t Extent>
+inline std::ostream& operator<<(std::ostream& out, const std::span<T, Extent>& s);
 template<class A, std::size_t N, class Alloc>
 inline std::ostream& operator<<(std::ostream& out, const boost::container::small_vector<A,N,Alloc>& v);
 template<class A, class Comp, class Alloc>
@@ -137,6 +140,19 @@ inline std::ostream& operator<<(std::ostream& out, const std::vector<A,Alloc>& v
   return out;
 }
 
+template<class T, std::size_t Extent>
+inline std::ostream& operator<<(std::ostream& out, const std::span<T, Extent>& s) {
+  bool first = true;
+  out << "[";
+  for (const auto& p : s) {
+    if (!first) out << ",";
+    out << p;
+    first = false;
+  }
+  out << "]";
+  return out;
+}
+
 template<class A, std::size_t N, class Alloc>
 inline std::ostream& operator<<(std::ostream& out, const boost::container::small_vector<A,N,Alloc>& v) {
   bool first = true;