From 69bd481fe6870af7d6237133b0f1e30d6d87328f Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 29 May 2025 08:58:08 -0400 Subject: [PATCH] common: break print template into separate header To avoid pulling in all the debug includes for some primitive headers. Signed-off-by: Patrick Donnelly --- src/common/CanHasPrint.h | 29 +++++++++++++++++++++++++++++ src/common/dout.h | 13 +------------ 2 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 src/common/CanHasPrint.h diff --git a/src/common/CanHasPrint.h b/src/common/CanHasPrint.h new file mode 100644 index 00000000000..9f1140c56f4 --- /dev/null +++ b/src/common/CanHasPrint.h @@ -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 +#include + +template +concept HasPrint = requires(T t, std::ostream& u) { + { t.print(u) } -> std::same_as; +}; + +template requires HasPrint +static inline std::ostream& operator<<(std::ostream& out, T&& t) +{ + t.print(out); + return out; +} diff --git a/src/common/dout.h b/src/common/dout.h index bc9be3b9595..2a3cc87143b 100644 --- a/src/common/dout.h +++ b/src/common/dout.h @@ -18,6 +18,7 @@ #include +#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 -concept HasPrint = requires(T t, std::ostream& u) { - { t.print(u) } -> std::same_as; -}; - -template requires HasPrint -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; -- 2.39.5