fix: explicit fmt usage added

This commit is contained in:
Mateusz Pusz
2021-09-17 09:48:33 +02:00
parent ddb6e6a90a
commit 3a997e5314
4 changed files with 34 additions and 34 deletions
+2 -2
View File
@@ -110,7 +110,7 @@ struct fmt::formatter<geographic::latitude> : formatter<geographic::latitude::va
template<typename FormatContext>
auto format(geographic::latitude lat, FormatContext& ctx)
{
format_to(ctx.out(), fmt::runtime(lat.value() > 0 ? "N" : "S"));
fmt::format_to(ctx.out(), fmt::runtime(lat.value() > 0 ? "N" : "S"));
return formatter<geographic::latitude::value_type>::format(lat.value() > 0 ? lat.value() : -lat.value(), ctx);
}
};
@@ -120,7 +120,7 @@ struct fmt::formatter<geographic::longitude> : formatter<geographic::longitude::
template<typename FormatContext>
auto format(geographic::longitude lon, FormatContext& ctx)
{
format_to(ctx.out(), fmt::runtime(lon.value() > 0 ? "E" : "W"));
fmt::format_to(ctx.out(), fmt::runtime(lon.value() > 0 ? "E" : "W"));
return formatter<geographic::longitude::value_type>::format(lon.value() > 0 ? lon.value() : -lon.value(), ctx);
}
};
@@ -110,7 +110,7 @@ struct fmt::formatter<glide_computer::altitude> : formatter<units::isq::si::leng
auto format(glide_computer::altitude a, FormatContext& ctx)
{
formatter<units::isq::si::length<units::isq::si::metre>>::format(a.relative().common(), ctx);
return format_to(ctx.out(), " AMSL");
return fmt::format_to(ctx.out(), " AMSL");
}
};
+10 -10
View File
@@ -165,26 +165,26 @@ struct fmt::formatter<kalman::state<Qs...>> {
auto to_value_buffer = std::back_inserter(value_buffer);
if (specs.precision != -1) {
if constexpr(sizeof...(Qs) == 1)
format_to(to_value_buffer, "{1:%.{0}Q %q}", specs.precision, kalman::get<0>(s));
fmt::format_to(to_value_buffer, "{1:%.{0}Q %q}", specs.precision, kalman::get<0>(s));
else if constexpr(sizeof...(Qs) == 2)
format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q} }}", specs.precision, kalman::get<0>(s), kalman::get<1>(s));
fmt::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q} }}", specs.precision, kalman::get<0>(s), kalman::get<1>(s));
else
format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q}, {3:%.{0}Q %q} }}", specs.precision, kalman::get<0>(s), kalman::get<1>(s), kalman::get<2>(s));
fmt::format_to(to_value_buffer, "{{ {1:%.{0}Q %q}, {2:%.{0}Q %q}, {3:%.{0}Q %q} }}", specs.precision, kalman::get<0>(s), kalman::get<1>(s), kalman::get<2>(s));
}
else {
if constexpr(sizeof...(Qs) == 1)
format_to(to_value_buffer, "{}", kalman::get<0>(s));
fmt::format_to(to_value_buffer, "{}", kalman::get<0>(s));
else if constexpr(sizeof...(Qs) == 2)
format_to(to_value_buffer, "{{ {}, {} }}", kalman::get<0>(s), kalman::get<1>(s));
fmt::format_to(to_value_buffer, "{{ {}, {} }}", kalman::get<0>(s), kalman::get<1>(s));
else
format_to(to_value_buffer, "{{ {}, {}, {} }}", kalman::get<0>(s), kalman::get<1>(s), kalman::get<2>(s));
fmt::format_to(to_value_buffer, "{{ {}, {}, {} }}", kalman::get<0>(s), kalman::get<1>(s), kalman::get<2>(s));
}
basic_memory_buffer<char> global_format_buffer;
units::detail::global_format_specs<char> global_specs = { specs.fill, specs.align, specs.width };
units::detail::format_global_buffer(std::back_inserter(global_format_buffer), global_specs);
return format_to(ctx.out(), fmt::runtime(std::string_view(global_format_buffer.data(), global_format_buffer.size())),
return fmt::format_to(ctx.out(), fmt::runtime(std::string_view(global_format_buffer.data(), global_format_buffer.size())),
std::string_view(value_buffer.data(), value_buffer.size()));
}
private:
@@ -212,17 +212,17 @@ struct fmt::formatter<kalman::estimation<Q>> {
memory_buffer value_buffer;
auto to_value_buffer = std::back_inserter(value_buffer);
if (specs.precision != -1) {
format_to(to_value_buffer, "{0:%.{2}Q} ± {1:%.{2}Q} {0:%q}", q, sqrt(e.uncertainty), specs.precision);
fmt::format_to(to_value_buffer, "{0:%.{2}Q} ± {1:%.{2}Q} {0:%q}", q, sqrt(e.uncertainty), specs.precision);
}
else {
format_to(to_value_buffer, "{0:%Q} ± {1:%Q} {0:%q}", q, sqrt(e.uncertainty));
fmt::format_to(to_value_buffer, "{0:%Q} ± {1:%Q} {0:%q}", q, sqrt(e.uncertainty));
}
basic_memory_buffer<char> global_format_buffer;
units::detail::global_format_specs<char> global_specs = { specs.fill, specs.align, specs.width };
units::detail::format_global_buffer(std::back_inserter(global_format_buffer), global_specs);
return format_to(ctx.out(), fmt::runtime(std::string_view(global_format_buffer.data(), global_format_buffer.size())),
return fmt::format_to(ctx.out(), fmt::runtime(std::string_view(global_format_buffer.data(), global_format_buffer.size())),
std::string_view(value_buffer.data(), value_buffer.size()));
}
private: