From: Patrick Donnelly Date: Thu, 29 May 2025 12:58:08 +0000 (-0400) Subject: common: break print template into separate header X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bbac989ac11d9bc731b7f8eba918f7099fcfc988;p=ceph-ci.git common: break print template into separate header To avoid pulling in all the debug includes for some primitive headers. Signed-off-by: Patrick Donnelly --- 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 c2fb5e65e62..2ca41b307c4 100644 --- a/src/common/dout.h +++ b/src/common/dout.h @@ -19,6 +19,7 @@ #include +#include "common/CanHasPrint.h" #include "include/ceph_assert.h" #include "include/common_fwd.h" #ifdef WITH_CRIMSON @@ -44,18 +45,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;