Skip to content

Commit

Permalink
fmt usage fixes
Browse files Browse the repository at this point in the history
Make format() functions const, prefix format_parse_context with fmt::.
The latter is somehow needed when building opendigitizer with 14.0.1.
  • Loading branch information
frankosterfeld committed Oct 2, 2024
1 parent 08d18ff commit 19aa11c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ static_assert(std::is_default_constructible_v<Device::Stream<float, SOAPY_SDR_RX

template<>
struct fmt::formatter<SoapySDRRange> {
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<typename FormatContext>
auto format(const gr::blocks::soapy::Range& range, FormatContext& ctx) const noexcept {
Expand Down
2 changes: 1 addition & 1 deletion core/include/gnuradio-4.0/BlockModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ struct fmt::formatter<gr::Edge> {
}

template<typename FormatContext>
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) {
Expand Down
2 changes: 1 addition & 1 deletion core/include/gnuradio-4.0/Sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ struct fmt::formatter<gr::Sequence> {
}

template<typename FormatContext>
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());
}
};
Expand Down
2 changes: 1 addition & 1 deletion core/include/gnuradio-4.0/annotated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ struct fmt::formatter<gr::Annotated<T, description, Arguments...>> {
}

template<typename FormatContext>
constexpr auto format(const gr::Annotated<T, description, Arguments...>& annotated, FormatContext& ctx) {
constexpr auto format(const gr::Annotated<T, description, Arguments...>& annotated, FormatContext& ctx) const {
// TODO: add switch for printing only brief and/or meta-information
return value_formatter.format(annotated.value, ctx);
}
Expand Down
2 changes: 1 addition & 1 deletion core/include/gnuradio-4.0/thread/thread_affinity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ struct fmt::formatter<gr::thread_pool::thread::Policy> {
}

template<typename FormatContext>
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;
Expand Down
10 changes: 5 additions & 5 deletions meta/include/gnuradio-4.0/meta/formatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct fmt::formatter<std::complex<T>> {
// simplified formatter for UncertainValue
template<gr::arithmetic_or_complex_like T>
struct fmt::formatter<gr::UncertainValue<T>> {
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<typename FormatContext>
constexpr auto format(const gr::UncertainValue<T>& value, FormatContext& ctx) const noexcept {
Expand Down Expand Up @@ -126,7 +126,7 @@ constexpr std::string join(const Container& container, const Separator& separato

template<>
struct fmt::formatter<pmtv::map_t::value_type> {
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<typename FormatContext>
auto format(const pmtv::map_t::value_type& kv, FormatContext& ctx) const noexcept {
Expand All @@ -136,7 +136,7 @@ struct fmt::formatter<pmtv::map_t::value_type> {

template<pmtv::IsPmt T>
struct fmt::formatter<T> { // 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<typename FormatContext>
auto format(const T& value, FormatContext& ctx) const noexcept {
Expand Down Expand Up @@ -180,7 +180,7 @@ struct fmt::formatter<T> { // alternate pmtv formatter optimised for compile-tim

template<>
struct fmt::formatter<pmtv::map_t> {
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<typename FormatContext>
constexpr auto format(const pmtv::map_t& value, FormatContext& ctx) const noexcept {
Expand All @@ -194,7 +194,7 @@ template<>
struct fmt::formatter<std::vector<bool>> {
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++;
Expand Down

0 comments on commit 19aa11c

Please sign in to comment.