From: Patrick Donnelly Date: Tue, 16 Jan 2024 18:59:47 +0000 (-0500) Subject: common: provide a template for object dumps X-Git-Tag: v19.1.0~193^2~59 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e577e26e9c84f5278cb18d685c1693a2a5bdb6c8;p=ceph.git common: provide a template for object dumps Signed-off-by: Patrick Donnelly (cherry picked from commit 92df0fcc649345f438d0d7cc6fab658c02060f07) --- diff --git a/src/common/dout.h b/src/common/dout.h index 4cd60efff8fe..8e27a0b1b433 100644 --- a/src/common/dout.h +++ b/src/common/dout.h @@ -44,6 +44,18 @@ 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;