mirror of
https://github.com/mpusz/mp-units.git
synced 2026-01-28 01:52:27 +01:00
feat: std::format support for compliant compilers added
This commit is contained in:
@@ -21,16 +21,11 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "glide_computer.h"
|
||||
#include <units/bits/external/hacks.h>
|
||||
#include <units/bits/fmt_hacks.h>
|
||||
#include <units/chrono.h>
|
||||
#include <units/generic/dimensionless.h>
|
||||
#include <units/isq/si/international/length.h>
|
||||
|
||||
UNITS_DIAGNOSTIC_PUSH
|
||||
UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE
|
||||
#include <fmt/format.h>
|
||||
UNITS_DIAGNOSTIC_POP
|
||||
|
||||
#include <array>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
@@ -90,7 +85,7 @@ void print(const R& gliders)
|
||||
std::cout << "- Name: " << g.name << "\n";
|
||||
std::cout << "- Polar:\n";
|
||||
for (const auto& p : g.polar)
|
||||
fmt::print(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, units::quantity_cast<units::one>(glide_ratio(g.polar[0])));
|
||||
std::cout << STD_FMT::format(" * {:%.4Q %q} @ {:%.1Q %q} -> {:%.1Q %q}\n", p.climb, p.v, units::quantity_cast<units::one>(glide_ratio(g.polar[0])));
|
||||
std::cout << "\n";
|
||||
}
|
||||
}
|
||||
@@ -104,8 +99,8 @@ void print(const R& conditions)
|
||||
for (const auto& c : conditions) {
|
||||
std::cout << "- " << c.first << "\n";
|
||||
const auto& w = c.second;
|
||||
std::cout << " * Cloud base: " << fmt::format("{:%.0Q %q}", w.cloud_base) << " AGL\n";
|
||||
std::cout << " * Thermals strength: " << fmt::format("{:%.1Q %q}", w.thermal_strength) << "\n";
|
||||
std::cout << " * Cloud base: " << STD_FMT::format("{:%.0Q %q}", w.cloud_base) << " AGL\n";
|
||||
std::cout << " * Thermals strength: " << STD_FMT::format("{:%.1Q %q}", w.thermal_strength) << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
}
|
||||
@@ -117,7 +112,7 @@ void print(const R& waypoints)
|
||||
std::cout << "Waypoints:\n";
|
||||
std::cout << "==========\n";
|
||||
for (const auto& w : waypoints)
|
||||
std::cout << fmt::format("- {}: {} {}, {:%.1Q %q}\n", w.name, w.pos.lat, w.pos.lon, w.alt);
|
||||
std::cout << STD_FMT::format("- {}: {} {}, {:%.1Q %q}\n", w.name, w.pos.lat, w.pos.lon, w.alt);
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -128,11 +123,11 @@ void print(const task& t)
|
||||
|
||||
std::cout << "- Start: " << t.get_start().name << "\n";
|
||||
std::cout << "- Finish: " << t.get_finish().name << "\n";
|
||||
std::cout << "- Length: " << fmt::format("{:%.1Q %q}", t.get_length()) << "\n";
|
||||
std::cout << "- Length: " << STD_FMT::format("{:%.1Q %q}", t.get_length()) << "\n";
|
||||
|
||||
std::cout << "- Legs: " << "\n";
|
||||
for (const auto& l : t.get_legs())
|
||||
std::cout << fmt::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length());
|
||||
std::cout << STD_FMT::format(" * {} -> {} ({:%.1Q %q})\n", l.begin().name, l.end().name, l.get_length());
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -140,7 +135,7 @@ void print(const safety& s)
|
||||
{
|
||||
std::cout << "Safety:\n";
|
||||
std::cout << "=======\n";
|
||||
std::cout << "- Min AGL separation: " << fmt::format("{:%.0Q %q}", s.min_agl_height) << "\n";
|
||||
std::cout << "- Min AGL separation: " << STD_FMT::format("{:%.0Q %q}", s.min_agl_height) << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -149,8 +144,8 @@ void print(const aircraft_tow& tow)
|
||||
std::cout << "Tow:\n";
|
||||
std::cout << "====\n";
|
||||
std::cout << "- Type: aircraft\n";
|
||||
std::cout << "- Height: " << fmt::format("{:%.0Q %q}", tow.height_agl) << "\n";
|
||||
std::cout << "- Performance: " << fmt::format("{:%.1Q %q}", tow.performance) << "\n";
|
||||
std::cout << "- Height: " << STD_FMT::format("{:%.0Q %q}", tow.height_agl) << "\n";
|
||||
std::cout << "- Performance: " << STD_FMT::format("{:%.1Q %q}", tow.performance) << "\n";
|
||||
std::cout << "\n";
|
||||
}
|
||||
|
||||
@@ -179,7 +174,7 @@ void example()
|
||||
for (const auto& c : weather_conditions) {
|
||||
std::string txt = "Scenario: Glider = " + g.name + ", Weather = " + c.first;
|
||||
std::cout << txt << "\n";
|
||||
fmt::print("{0:=^{1}}\n\n", "", txt.size());
|
||||
std::cout << STD_FMT::format("{0:=^{1}}\n\n", "", txt.size());
|
||||
|
||||
estimate(start_time, g, c.second, t, sfty, tow);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user