diff --git a/example/glide_computer/include/geographic.h b/example/glide_computer/include/geographic.h index a8c7ae7a..8c7a68c4 100644 --- a/example/glide_computer/include/geographic.h +++ b/example/glide_computer/include/geographic.h @@ -105,7 +105,7 @@ struct STD_FMT::formatter : formatter auto format(geographic::latitude lat, FormatContext& ctx) { - STD_FMT::format_to(ctx.out(), FMT_RUNTIME(lat.value() > 0 ? "N" : "S")); + STD_FMT::vformat_to(ctx.out(), lat.value() > 0 ? "N" : "S", {}); return formatter::format(lat.value() > 0 ? lat.value() : -lat.value(), ctx); } }; @@ -115,7 +115,7 @@ struct STD_FMT::formatter : formatter auto format(geographic::longitude lon, FormatContext& ctx) { - STD_FMT::format_to(ctx.out(), FMT_RUNTIME(lon.value() > 0 ? "E" : "W")); + STD_FMT::vformat_to(ctx.out(), lon.value() > 0 ? "E" : "W", {}); return formatter::format(lon.value() > 0 ? lon.value() : -lon.value(), ctx); } }; diff --git a/example/kalman_filter/kalman.h b/example/kalman_filter/kalman.h index d8c54a89..46b0354f 100644 --- a/example/kalman_filter/kalman.h +++ b/example/kalman_filter/kalman.h @@ -184,7 +184,7 @@ struct STD_FMT::formatter> { units::detail::quantity_global_format_specs global_specs = { specs.fill, specs.align, specs.width }; units::detail::format_global_buffer(std::back_inserter(global_format_buffer), global_specs); - return STD_FMT::format_to(ctx.out(), FMT_RUNTIME(global_format_buffer), value_buffer); + return STD_FMT::vformat_to(ctx.out(), global_format_buffer, STD_FMT::make_format_args(value_buffer)); } private: units::detail::dynamic_format_specs specs; @@ -221,7 +221,7 @@ struct STD_FMT::formatter> { units::detail::quantity_global_format_specs global_specs = { specs.fill, specs.align, specs.width }; units::detail::format_global_buffer(std::back_inserter(global_format_buffer), global_specs); - return STD_FMT::format_to(ctx.out(), FMT_RUNTIME(global_format_buffer), value_buffer); + return STD_FMT::vformat_to(ctx.out(), global_format_buffer, STD_FMT::make_format_args(value_buffer)); } private: units::detail::dynamic_format_specs specs; diff --git a/src/core-fmt/include/units/bits/fmt_hacks.h b/src/core-fmt/include/units/bits/fmt_hacks.h index 814a0cb3..a4db23f2 100644 --- a/src/core-fmt/include/units/bits/fmt_hacks.h +++ b/src/core-fmt/include/units/bits/fmt_hacks.h @@ -42,7 +42,6 @@ UNITS_DIAGNOSTIC_IGNORE_SHADOW UNITS_DIAGNOSTIC_POP #define STD_FMT fmt -#define FMT_RUNTIME(arg) fmt::runtime(arg) #define FMT_LOCALE(loc) (loc).template get() #define FMT_TO_ARG_ID(arg) static_cast(arg) #define FMT_FROM_ARG_ID(arg) static_cast(arg) @@ -56,7 +55,6 @@ UNITS_DIAGNOSTIC_POP #include #define STD_FMT std -#define FMT_RUNTIME(arg) arg #define FMT_LOCALE(loc) loc #define FMT_TO_ARG_ID(arg) arg #define FMT_FROM_ARG_ID(arg) arg diff --git a/src/core-fmt/include/units/format.h b/src/core-fmt/include/units/format.h index b7dbdf97..5e97e4d5 100644 --- a/src/core-fmt/include/units/format.h +++ b/src/core-fmt/include/units/format.h @@ -233,9 +233,9 @@ template STD_FMT::format_to(to_buffer, "}}"); if (rep_specs.localized) { - return STD_FMT::format_to(out, FMT_LOCALE(loc), FMT_RUNTIME(buffer), val); + return STD_FMT::vformat_to(out, FMT_LOCALE(loc), buffer, STD_FMT::make_format_args(val)); } - return STD_FMT::format_to(out, FMT_RUNTIME(buffer), val); + return STD_FMT::vformat_to(out, buffer, STD_FMT::make_format_args(val)); } // Creates a global format string @@ -457,7 +457,7 @@ public: // Format the `quantity buffer` using specs from `global_format_buffer` // In the example, equivalent to STD_FMT::format("{:*^10}", "1.2_m") - return STD_FMT::format_to(ctx.out(), FMT_RUNTIME(global_format_buffer), quantity_buffer); + return STD_FMT::vformat_to(ctx.out(), global_format_buffer, STD_FMT::make_format_args(quantity_buffer)); } } }; diff --git a/test/unit_test/runtime/fmt_test.cpp b/test/unit_test/runtime/fmt_test.cpp index 2c0e4265..6395872a 100644 --- a/test/unit_test/runtime/fmt_test.cpp +++ b/test/unit_test/runtime/fmt_test.cpp @@ -1034,12 +1034,12 @@ TEST_CASE("precision specification for integral representation should throw", "[ { SECTION("full format {:%Q %q} on a quantity") { - REQUIRE_THROWS_MATCHES(STD_FMT::format(FMT_RUNTIME("{:%.1Q %q}"), 1_q_m), STD_FMT::format_error, Message("precision not allowed for integral quantity representation")); + REQUIRE_THROWS_MATCHES(STD_FMT::format("{:%.1Q %q}", 1_q_m), STD_FMT::format_error, Message("precision not allowed for integral quantity representation")); } SECTION("value only format {:%Q} on a quantity") { - REQUIRE_THROWS_MATCHES(STD_FMT::format(FMT_RUNTIME("{:%.1Q}"), 1_q_m), STD_FMT::format_error, Message("precision not allowed for integral quantity representation")); + REQUIRE_THROWS_MATCHES(STD_FMT::format("{:%.1Q}", 1_q_m), STD_FMT::format_error, Message("precision not allowed for integral quantity representation")); } }