From ddb6e6a90a14974a8987e18f494387fc316c8024 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 17 Sep 2021 09:47:59 +0200 Subject: [PATCH 1/3] fix: missing algorithm header added --- src/core-fmt/include/units/format.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core-fmt/include/units/format.h b/src/core-fmt/include/units/format.h index 14f28cb3..4dd61804 100644 --- a/src/core-fmt/include/units/format.h +++ b/src/core-fmt/include/units/format.h @@ -24,6 +24,8 @@ #include #include + +#include #include // IWYU pragma: begin_exports From 3a997e5314782f03efbd60a0bf04c8ce7db8e3aa Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 17 Sep 2021 09:48:33 +0200 Subject: [PATCH 2/3] fix: explicit `fmt` usage added --- example/glide_computer/include/geographic.h | 4 +- .../glide_computer/include/glide_computer.h | 2 +- example/kalman_filter/kalman.h | 20 ++++----- src/core-fmt/include/units/format.h | 42 +++++++++---------- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/example/glide_computer/include/geographic.h b/example/glide_computer/include/geographic.h index fd2ca4db..dac2e625 100644 --- a/example/glide_computer/include/geographic.h +++ b/example/glide_computer/include/geographic.h @@ -110,7 +110,7 @@ struct fmt::formatter : formatter 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::format(lat.value() > 0 ? lat.value() : -lat.value(), ctx); } }; @@ -120,7 +120,7 @@ struct fmt::formatter : formatter 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::format(lon.value() > 0 ? lon.value() : -lon.value(), ctx); } }; diff --git a/example/glide_computer/include/glide_computer.h b/example/glide_computer/include/glide_computer.h index ef9631f7..bc5416fd 100644 --- a/example/glide_computer/include/glide_computer.h +++ b/example/glide_computer/include/glide_computer.h @@ -110,7 +110,7 @@ struct fmt::formatter : formatter>::format(a.relative().common(), ctx); - return format_to(ctx.out(), " AMSL"); + return fmt::format_to(ctx.out(), " AMSL"); } }; diff --git a/example/kalman_filter/kalman.h b/example/kalman_filter/kalman.h index 000153b0..dfa4a334 100644 --- a/example/kalman_filter/kalman.h +++ b/example/kalman_filter/kalman.h @@ -165,26 +165,26 @@ struct fmt::formatter> { 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 global_format_buffer; units::detail::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 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> { 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 global_format_buffer; units::detail::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 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: diff --git a/src/core-fmt/include/units/format.h b/src/core-fmt/include/units/format.h index 4dd61804..8da93474 100644 --- a/src/core-fmt/include/units/format.h +++ b/src/core-fmt/include/units/format.h @@ -224,37 +224,37 @@ namespace units { case fmt::sign::none: break; case fmt::sign::plus: - format_to(to_buffer, "+"); + fmt::format_to(to_buffer, "+"); break; case fmt::sign::minus: - format_to(to_buffer, "-"); + fmt::format_to(to_buffer, "-"); break; case fmt::sign::space: - format_to(to_buffer, " "); + fmt::format_to(to_buffer, " "); break; } if (rep_specs.alt) { - format_to(to_buffer, "#"); + fmt::format_to(to_buffer, "#"); } auto type = rep_specs.type; if (auto precision = rep_specs.precision; precision >= 0) { - format_to(to_buffer, ".{}{}", precision, type == '\0' ? 'f' : type); + fmt::format_to(to_buffer, ".{}{}", precision, type == '\0' ? 'f' : type); } else if constexpr (treat_as_floating_point) { - format_to(to_buffer, "{}", type == '\0' ? 'g' : type); + fmt::format_to(to_buffer, "{}", type == '\0' ? 'g' : type); } else { if (type != '\0') { - format_to(to_buffer, "{}", type); + fmt::format_to(to_buffer, "{}", type); } } if (rep_specs.use_locale) { - format_to(to_buffer, "L"); + fmt::format_to(to_buffer, "L"); } fmt::format_to(to_buffer, "}}"); if (rep_specs.use_locale and static_cast(loc)) { - return format_to(out, loc.template get(), fmt::runtime(std::string_view(buffer.data(), buffer.size())), val); + return fmt::format_to(out, loc.template get(), fmt::runtime(std::string_view(buffer.data(), buffer.size())), val); } - return format_to(out, fmt::runtime(std::string_view(buffer.data(), buffer.size())), val); + return fmt::format_to(out, fmt::runtime(std::string_view(buffer.data(), buffer.size())), val); } // Creates a global format string @@ -262,27 +262,27 @@ namespace units { template inline OutputIt format_global_buffer(OutputIt out, const global_format_specs& specs) { - format_to(out, "{{:"); + fmt::format_to(out, "{{:"); if (specs.fill.size() != 1 || specs.fill[0] != ' ') { - format_to(out, "{}", specs.fill.data()); + fmt::format_to(out, "{}", specs.fill.data()); } switch (specs.align) { case fmt::align_t::left: - format_to(out, "<"); + fmt::format_to(out, "<"); break; case fmt::align_t::right: - format_to(out, ">"); + fmt::format_to(out, ">"); break; case fmt::align_t::center: - format_to(out, "^"); + fmt::format_to(out, "^"); break; default: break; } if (specs.width >= 1) { - format_to(out, "{}", specs.width); + fmt::format_to(out, "{}", specs.width); } - return format_to(out, "}}"); + return fmt::format_to(out, "}}"); } template @@ -319,10 +319,10 @@ namespace units { { auto txt = unit_text(); if(unit_specs.modifier == 'A') { - format_to(out, "{}", txt.ascii().c_str()); + fmt::format_to(out, "{}", txt.ascii().c_str()); } else { - format_to(out, "{}", txt.standard().c_str()); + fmt::format_to(out, "{}", txt.standard().c_str()); } } }; @@ -495,7 +495,7 @@ public: constexpr auto symbol = units::detail::unit_text(); if(symbol.standard().size()) { *to_quantity_buffer++ = CharT(' '); - format_to(to_quantity_buffer, "{}", symbol.standard().c_str()); + fmt::format_to(to_quantity_buffer, "{}", symbol.standard().c_str()); } } else { @@ -511,6 +511,6 @@ public: // Format the `quantity buffer` using specs from `global_format_buffer` // In the example, equivalent to fmt::format("{:*^10}", "1.2_m") - return format_to(ctx.out(), fmt::runtime(std::basic_string_view(global_format_buffer.data(), global_format_buffer.size())), std::string_view(quantity_buffer.data(), quantity_buffer.size())); + return fmt::format_to(ctx.out(), fmt::runtime(std::basic_string_view(global_format_buffer.data(), global_format_buffer.size())), std::string_view(quantity_buffer.data(), quantity_buffer.size())); } }; From df33d923e514a791d63ba7f0082f28bb3f023fd6 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 17 Sep 2021 13:29:30 +0200 Subject: [PATCH 3/3] ci: Ninja set as the default CMake generator --- .github/workflows/ci-conan.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-conan.yml b/.github/workflows/ci-conan.yml index 4eb2ad67..2c84fc2d 100644 --- a/.github/workflows/ci-conan.yml +++ b/.github/workflows/ci-conan.yml @@ -136,6 +136,7 @@ jobs: if [[ "${{ matrix.config.compiler.type }}" == "GCC" || "${{ matrix.config.compiler.type }}" == "CLANG" ]]; then conan profile update settings.compiler.libcxx=${{ matrix.config.lib }} default fi + conan profile update conf.tools.cmake.cmaketoolchain:generator=Ninja default conan profile show default # - name: Add support for clang-13 to Conan's settings.yml # # TODO Remove when Conan will support clang-13