From 19aa11c35eb25419e4344a028fcc1c06246e062d Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 2 Oct 2024 13:14:45 +0200 Subject: [PATCH] fmt usage fixes Make format() functions const, prefix format_parse_context with fmt::. The latter is somehow needed when building opendigitizer with 14.0.1. --- .../include/gnuradio-4.0/soapy/SoapyRaiiWrapper.hpp | 2 +- core/include/gnuradio-4.0/BlockModel.hpp | 2 +- core/include/gnuradio-4.0/Sequence.hpp | 2 +- core/include/gnuradio-4.0/annotated.hpp | 2 +- core/include/gnuradio-4.0/thread/thread_affinity.hpp | 2 +- meta/include/gnuradio-4.0/meta/formatter.hpp | 10 +++++----- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/blocks/soapy/include/gnuradio-4.0/soapy/SoapyRaiiWrapper.hpp b/blocks/soapy/include/gnuradio-4.0/soapy/SoapyRaiiWrapper.hpp index d53678aa4..9f0f9170c 100644 --- a/blocks/soapy/include/gnuradio-4.0/soapy/SoapyRaiiWrapper.hpp +++ b/blocks/soapy/include/gnuradio-4.0/soapy/SoapyRaiiWrapper.hpp @@ -780,7 +780,7 @@ static_assert(std::is_default_constructible_v struct fmt::formatter { - constexpr auto parse(format_parse_context& ctx) const noexcept { return ctx.begin(); } + constexpr auto parse(fmt::format_parse_context& ctx) const noexcept { return ctx.begin(); } template auto format(const gr::blocks::soapy::Range& range, FormatContext& ctx) const noexcept { diff --git a/core/include/gnuradio-4.0/BlockModel.hpp b/core/include/gnuradio-4.0/BlockModel.hpp index bb7974fd3..e19692aba 100644 --- a/core/include/gnuradio-4.0/BlockModel.hpp +++ b/core/include/gnuradio-4.0/BlockModel.hpp @@ -513,7 +513,7 @@ struct fmt::formatter { } template - auto format(const gr::Edge& e, FormatContext& ctx) { + auto format(const gr::Edge& e, FormatContext& ctx) const { const auto& name = [this](const gr::BlockModel* block) { return (formatSpecifier == 'l') ? block->uniqueName() : block->name(); }; const auto portIndex = [](const gr::PortDefinition& port) { diff --git a/core/include/gnuradio-4.0/Sequence.hpp b/core/include/gnuradio-4.0/Sequence.hpp index 164edcb9f..36f8b2678 100644 --- a/core/include/gnuradio-4.0/Sequence.hpp +++ b/core/include/gnuradio-4.0/Sequence.hpp @@ -177,7 +177,7 @@ struct fmt::formatter { } template - auto format(gr::Sequence const& value, FormatContext& ctx) { + auto format(gr::Sequence const& value, FormatContext& ctx) const { return fmt::format_to(ctx.out(), "{}", value.value()); } }; diff --git a/core/include/gnuradio-4.0/annotated.hpp b/core/include/gnuradio-4.0/annotated.hpp index ae5d849fb..ed76395b3 100644 --- a/core/include/gnuradio-4.0/annotated.hpp +++ b/core/include/gnuradio-4.0/annotated.hpp @@ -423,7 +423,7 @@ struct fmt::formatter> { } template - constexpr auto format(const gr::Annotated& annotated, FormatContext& ctx) { + constexpr auto format(const gr::Annotated& annotated, FormatContext& ctx) const { // TODO: add switch for printing only brief and/or meta-information return value_formatter.format(annotated.value, ctx); } diff --git a/core/include/gnuradio-4.0/thread/thread_affinity.hpp b/core/include/gnuradio-4.0/thread/thread_affinity.hpp index 9273f162a..43c13aa16 100644 --- a/core/include/gnuradio-4.0/thread/thread_affinity.hpp +++ b/core/include/gnuradio-4.0/thread/thread_affinity.hpp @@ -258,7 +258,7 @@ struct fmt::formatter { } template - auto format(Policy policy, FormatContext& ctx) { + auto format(Policy policy, FormatContext& ctx) const { std::string policy_name; switch (policy) { case Policy::UNKNOWN: policy_name = "UNKNOWN"; break; diff --git a/meta/include/gnuradio-4.0/meta/formatter.hpp b/meta/include/gnuradio-4.0/meta/formatter.hpp index 82964bb37..1203bd652 100644 --- a/meta/include/gnuradio-4.0/meta/formatter.hpp +++ b/meta/include/gnuradio-4.0/meta/formatter.hpp @@ -82,7 +82,7 @@ struct fmt::formatter> { // simplified formatter for UncertainValue template struct fmt::formatter> { - constexpr auto parse(format_parse_context& ctx) const noexcept -> decltype(ctx.begin()) { return ctx.begin(); } + constexpr auto parse(fmt::format_parse_context& ctx) const noexcept -> decltype(ctx.begin()) { return ctx.begin(); } template constexpr auto format(const gr::UncertainValue& value, FormatContext& ctx) const noexcept { @@ -126,7 +126,7 @@ constexpr std::string join(const Container& container, const Separator& separato template<> struct fmt::formatter { - constexpr auto parse(format_parse_context& ctx) const noexcept -> decltype(ctx.begin()) { return ctx.begin(); } + constexpr auto parse(fmt::format_parse_context& ctx) const noexcept -> decltype(ctx.begin()) { return ctx.begin(); } template auto format(const pmtv::map_t::value_type& kv, FormatContext& ctx) const noexcept { @@ -136,7 +136,7 @@ struct fmt::formatter { template struct fmt::formatter { // alternate pmtv formatter optimised for compile-time not runtime - constexpr auto parse(format_parse_context& ctx) const noexcept -> decltype(ctx.begin()) { return ctx.begin(); } + constexpr auto parse(fmt::format_parse_context& ctx) const noexcept -> decltype(ctx.begin()) { return ctx.begin(); } template auto format(const T& value, FormatContext& ctx) const noexcept { @@ -180,7 +180,7 @@ struct fmt::formatter { // alternate pmtv formatter optimised for compile-tim template<> struct fmt::formatter { - constexpr auto parse(format_parse_context& ctx) const noexcept -> decltype(ctx.begin()) { return ctx.begin(); } + constexpr auto parse(fmt::format_parse_context& ctx) const noexcept -> decltype(ctx.begin()) { return ctx.begin(); } template constexpr auto format(const pmtv::map_t& value, FormatContext& ctx) const noexcept { @@ -194,7 +194,7 @@ template<> struct fmt::formatter> { char presentation = 'c'; - constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + constexpr auto parse(fmt::format_parse_context& ctx) -> decltype(ctx.begin()) { auto it = ctx.begin(), end = ctx.end(); if (it != end && (*it == 's' || *it == 'c')) { presentation = *it++;