From fe2f8bb2393e496ae3b3a94b3ace10002aacf93e Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 14 Jul 2024 11:54:42 +0800 Subject: [PATCH 1/2] do not put fmt::formatter into fmt namespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit as fmt::formatter already has the namespace qualifier. otherwise, the build would fail when building with fmt 11, like: ``` /usr/include/boxed-cpp/boxed.hpp:218:8: error: extra qualification not allowed [-fpermissive] 218 | struct fmt::formatter> | ^~~ In file included from /usr/include/fmt/format.h:41, from /usr/include/boxed-cpp/boxed.hpp:211: /usr/include/fmt/base.h: In instantiation of ‘static void fmt::v11::detail::value::format_custom_arg(void*, typename Context::parse_context_type&, Context&) [with T = boxed::detail::boxed; Formatter = fmt::v11::formatter, char, void>; Context = fmt::v11::context; typename Context::parse_context_type = fmt::v11::basic_format_parse_context]’: /usr/include/fmt/base.h:1373:19: required from ‘constexpr fmt::v11::detail::value::value(T&) [with T = boxed::detail::boxed; Context = fmt::v11::context]’ 1373 | custom.format = format_custom_arg< | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ 1374 | value_type, typename Context::template formatter_type>; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/fmt/base.h:1631:41: required from ‘constexpr fmt::v11::detail::format_arg_store fmt::v11::make_format_args(T& ...) [with Context = context; T = {boxed::detail::boxed, boxed::detail::boxed}; long unsigned int NUM_ARGS = 2; long unsigned int NUM_NAMED_ARGS = 0; long long unsigned int DESC = 255; typename std::enable_if<(NUM_NAMED_ARGS == 0), int>::type = 0]’ 1631 | return {arg_mapper().map(val)}; | ^ ``` Signed-off-by: Kefu Chai --- include/boxed-cpp/boxed.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/boxed-cpp/boxed.hpp b/include/boxed-cpp/boxed.hpp index 3986c8b..4d8598c 100644 --- a/include/boxed-cpp/boxed.hpp +++ b/include/boxed-cpp/boxed.hpp @@ -212,9 +212,6 @@ struct hash> #include // clang-format on -namespace fmt -{ - template struct fmt::formatter> { @@ -226,6 +223,5 @@ struct fmt::formatter> } }; -} // namespace fmt #endif // }}} From e28b094dc811e174b5605d33611b0d638c5ad7ea Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 14 Jul 2024 18:20:55 +0800 Subject: [PATCH 2/2] add make fmt::formatter() const MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit otherwise the tree fails to build: ``` /usr/include/fmt/base.h:1392:29: error: passing ‘const fmt::v11::formatter, char, void>’ as ‘this’ argument discards qualifiers [-fpermissive] 1392 | ctx.advance_to(cf.format(*static_cast(arg), ctx)); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/boxed-cpp/boxed.hpp:219:10: note: in call to ‘auto fmt::v11::formatter >::format(const boxed::detail::boxed&, fmt::v11::format_context&) [with Type = unsigned int; Tag = vtpty::detail::tags::Width; fmt::v11::format_context = fmt::v11::context]’ 219 | auto format(boxed::detail::boxed const& val, fmt::format_context& ctx) | ^~~~~~ ``` Signed-off-by: Kefu Chai --- include/boxed-cpp/boxed.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boxed-cpp/boxed.hpp b/include/boxed-cpp/boxed.hpp index 4d8598c..dfc7e46 100644 --- a/include/boxed-cpp/boxed.hpp +++ b/include/boxed-cpp/boxed.hpp @@ -217,7 +217,7 @@ struct fmt::formatter> { constexpr auto parse(fmt::format_parse_context& ctx) { return ctx.begin(); } - auto format(boxed::detail::boxed const& val, fmt::format_context& ctx) + auto format(boxed::detail::boxed const& val, fmt::format_context& ctx) const { return fmt::format_to(ctx.out(), "{}", val.value); }