From db56af2e419244dbb6791c7b9c28ff9d018367ac Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 17 Jul 2024 09:49:26 +0800 Subject: [PATCH] replication_strategy: mark fmt::formatter<..>::format() const since fmt 11, it is required that the format() to be const, otherwise its caller in fmt library would not be able to call it. and compile would fail like: ``` /home/kefu/.local/bin/clang++ -DFMT_SHARED -DSCYLLA_BUILD_MODE=release -DSEASTAR_API_LEVEL=7 -DSEASTAR_LOGGER_COMPILE_TIME_FMT -DSEASTAR_LOGGER_TYPE_STDOUT -DSEASTAR_SCHEDULING_GROUPS_COUNT=16 -DSEASTAR_SSTRING -DXXH_PRIVATE_API -DCMAKE_INTDIR=\"RelWithDebInfo\" -I/home/kefu/dev/scylladb -I/home/kefu/dev/scylladb/seastar/include -I/home/kefu/dev/scylladb/build/seastar/gen/include -I/home/kefu/dev/scylladb/build/seastar/gen/src -I/home/kefu/dev/scylladb/build/gen -isystem /home/kefu/dev/scylladb/abseil -ffunction-sections -fdata-sections -O3 -g -gz -std=gnu++23 -fvisibility=hidden -Wall -Werror -Wextra -Wno-error=deprecated-declarations -Wimplicit-fallthrough -Wno-c++11-narrowing -Wno-deprecated-copy -Wno-mismatched-tags -Wno-missing-field-initializers -Wno-overloaded-virtual -Wno-unsupported-friend -Wno-enum-constexpr-conversion -Wno-unused-parameter -ffile-prefix-map=/home/kefu/dev/scylladb=. -march=westmere -Xclang -fexperimental-assignment-tracking=disabled -mllvm -inline-threshold=2500 -fno-slp-vectorize -U_FORTIFY_SOURCE -Werror=unused-result -MD -MT locator/CMakeFiles/scylla_locator.dir/RelWithDebInfo/abstract_replication_strategy.cc.o -MF locator/CMakeFiles/scylla_locator.dir/RelWithDebInfo/abstract_replication_strategy.cc.o.d -o locator/CMakeFiles/scylla_locator.dir/RelWithDebInfo/abstract_replication_strategy.cc.o -c /home/kefu/dev/scylladb/locator/abstract_replication_strategy.cc In file included from /home/kefu/dev/scylladb/locator/abstract_replication_strategy.cc:9: In file included from /home/kefu/dev/scylladb/locator/abstract_replication_strategy.hh:16: In file included from /home/kefu/dev/scylladb/gms/inet_address.hh:11: In file included from /usr/include/fmt/ostream.h:23: In file included from /usr/include/fmt/chrono.h:23: In file included from /usr/include/fmt/format.h:41: /usr/include/fmt/base.h:1393:23: error: no matching member function for call to 'format' 1393 | ctx.advance_to(cf.format(*static_cast(arg), ctx)); | ~~~^~~~~~ /usr/include/fmt/base.h:1374:21: note: in instantiation of function template specialization 'fmt::detail::value::format_custom_arg>' requested here 1374 | custom.format = format_custom_arg< | ^ /home/kefu/dev/scylladb/seastar/include/seastar/util/log.hh:299:33: note: in instantiation of function template specialization 'fmt::format_to' requested here 299 | return fmt::format_to(it, fmt.format, std::forward(args)...); | ^ /home/kefu/dev/scylladb/seastar/include/seastar/util/log.hh:428:9: note: in instantiation of function template specialization 'seastar::logger::log' requested here 428 | log(log_level::debug, std::move(fmt), std::forward(args)...); | ^ /home/kefu/dev/scylladb/locator/abstract_replication_strategy.cc:561:18: note: in instantiation of function template specialization 'seastar::logger::debug' requested here 561 | rslogger.debug("create_effective_replication_map: found {} [{}]", key, fmt::ptr(erm.get())); | ^ /home/kefu/dev/scylladb/locator/abstract_replication_strategy.hh:471:10: note: candidate function template not viable: 'this' argument has type 'const fmt::formatter', but method is not marked const 471 | auto format(const locator::vnode_effective_replication_map::factory_key& key, FormatContext& ctx) { | ^ 1 error generated. ``` Signed-off-by: Kefu Chai Closes scylladb/scylladb#19768 --- locator/abstract_replication_strategy.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locator/abstract_replication_strategy.hh b/locator/abstract_replication_strategy.hh index 29320ef7c4..6998415f7b 100644 --- a/locator/abstract_replication_strategy.hh +++ b/locator/abstract_replication_strategy.hh @@ -468,7 +468,7 @@ struct fmt::formatter { } template - auto format(const locator::vnode_effective_replication_map::factory_key& key, FormatContext& ctx) { + auto format(const locator::vnode_effective_replication_map::factory_key& key, FormatContext& ctx) const { std::ostringstream os; os << key; return fmt::format_to(ctx.out(), "{}", os.str());