]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common: break print template into separate header
authorPatrick Donnelly <pdonnell@ibm.com>
Thu, 29 May 2025 12:58:08 +0000 (08:58 -0400)
committerPatrick Donnelly <pdonnell@ibm.com>
Wed, 1 Oct 2025 18:46:47 +0000 (14:46 -0400)
To avoid pulling in all the debug includes for some primitive headers.

Signed-off-by: Patrick Donnelly <pdonnell@ibm.com>
src/common/CanHasPrint.h [new file with mode: 0644]
src/common/dout.h

diff --git a/src/common/CanHasPrint.h b/src/common/CanHasPrint.h
new file mode 100644 (file)
index 0000000..9f1140c
--- /dev/null
@@ -0,0 +1,29 @@
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2025 IBM, Inc.
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#pragma once
+
+#include <concepts>
+#include <iosfwd>
+
+template<typename T>
+concept HasPrint = requires(T t, std::ostream& u) {
+  { t.print(u) } -> std::same_as<void>;
+};
+
+template<typename T> requires HasPrint<T>
+static inline std::ostream& operator<<(std::ostream& out, T&& t)
+{
+  t.print(out);
+  return out;
+}
index bc9be3b9595428e3ad4e8577b700343c1a00e214..2a3cc87143ba96ad2f09d05f24fcd8b942f9bbc2 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <type_traits>
 
+#include "common/CanHasPrint.h"
 #include "include/ceph_assert.h"
 #include "include/common_fwd.h"
 #ifdef WITH_CRIMSON
@@ -43,18 +44,6 @@ inline std::ostream& operator<<(std::ostream& out, _bad_endl_use_dendl_t) {
   return out;
 }
 
-template<typename T>
-concept HasPrint = requires(T t, std::ostream& u) {
-  { t.print(u) } -> std::same_as<void>;
-};
-
-template<typename T> requires HasPrint<T>
-static inline std::ostream& operator<<(std::ostream& out, T&& t)
-{
-  t.print(out);
-  return out;
-}
-
 class DoutPrefixProvider {
 public:
   virtual std::ostream& gen_prefix(std::ostream& out) const = 0;