From: Kefu Chai Date: Wed, 26 Mar 2025 03:43:43 +0000 (+0800) Subject: src: migrate to fmt::formattable for format support X-Git-Tag: testing/wip-vshankar-testing-20250407.170244-debug~79^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0dc157830ca1a87737527487c4526d18970878a6;p=ceph-ci.git src: migrate to fmt::formattable for format support Replace custom has_formatter concept with fmtlib's fmt::formattable - Deprecate usage of fmt::has_formatter - Resolve compiler warnings with recent fmtlib versions The custom concept of has_formatter is no longer necessary with recent updates to the fmtlib library, as fmt::formattable was introduced in fmtlib v11.0.0. By switching to fmt::formattable, we simplify our code and stop using the deprecated `fmt::has_formatter` template. Signed-off-by: Kefu Chai --- diff --git a/src/common/bitset_set.h b/src/common/bitset_set.h index 5bd0be0ce07..12c98de99a4 100644 --- a/src/common/bitset_set.h +++ b/src/common/bitset_set.h @@ -412,7 +412,7 @@ class bitset_set { } std::string fmt_print() const - requires has_formatter { + requires fmt::formattable { std::string s = "{"; int c = (int)size(); for (auto k : *this) { diff --git a/src/common/fmt_common.h b/src/common/fmt_common.h index 474f6fbc324..cd891bfc93f 100644 --- a/src/common/fmt_common.h +++ b/src/common/fmt_common.h @@ -2,7 +2,9 @@ // vim: ts=8 sw=2 smarttab #pragma once +#include #include +#include /** * \file default fmtlib formatters for specifically-tagged types @@ -17,8 +19,13 @@ * such classes in Crimson. */ -template -concept has_formatter = fmt::has_formatter::value; +#if FMT_VERSION < 110000 +// TODO: drop me once fmt v11 is required +namespace fmt { + template + concept formattable = is_formattable, Char>::value>; +} +#endif /** * Tagging classes that provide support for default fmtlib formatting, diff --git a/src/common/interval_map.h b/src/common/interval_map.h index e363d938b78..470bfb37618 100644 --- a/src/common/interval_map.h +++ b/src/common/interval_map.h @@ -324,7 +324,7 @@ public: } std::string fmt_print() const - requires has_formatter { + requires fmt::formattable { std::string str = "{"; bool first = true; for (auto &&i: *this) { diff --git a/src/common/mini_flat_map.h b/src/common/mini_flat_map.h index 5e880f50d70..46abda51387 100644 --- a/src/common/mini_flat_map.h +++ b/src/common/mini_flat_map.h @@ -495,7 +495,7 @@ class mini_flat_map { } std::string fmt_print() const - requires has_formatter && has_formatter { + requires fmt::formattable && fmt::formattable { int c = (int)_size; std::string s = "{"; for (auto&& [k, v] : *this) { diff --git a/src/crimson/osd/scrub/scrub_machine.h b/src/crimson/osd/scrub/scrub_machine.h index f6cec5cba71..511e8aa865f 100644 --- a/src/crimson/osd/scrub/scrub_machine.h +++ b/src/crimson/osd/scrub/scrub_machine.h @@ -49,7 +49,7 @@ struct simple_event_t : sc::event { } }; -template +template struct value_event_t : sc::event { const V value; diff --git a/src/include/interval_set.h b/src/include/interval_set.h index e93ba7601e2..4ba12666e4f 100644 --- a/src/include/interval_set.h +++ b/src/include/interval_set.h @@ -263,7 +263,7 @@ class interval_set { } std::string fmt_print() const - requires has_formatter { + requires fmt::formattable { std::string s = "["; bool first = true; for (const auto& [start, len] : *this) { diff --git a/src/osd/scrubber/scrub_machine.h b/src/osd/scrubber/scrub_machine.h index f7f739692bf..5ae895d86df 100644 --- a/src/osd/scrubber/scrub_machine.h +++ b/src/osd/scrubber/scrub_machine.h @@ -105,7 +105,7 @@ OP_EV(ReplicaReserveReq); /// explicit release request from the Primary OP_EV(ReplicaRelease); -template +template struct value_event_t : sc::event { const V value;