mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-30 02:17:16 +02:00
refactor: All the macros refactored to have MP_UNITS_
prefix
This commit is contained in:
@ -53,25 +53,25 @@ struct Ship {
|
||||
template<Unit auto... Us, Quantity Q>
|
||||
auto fmt_line(const Q& q)
|
||||
{
|
||||
return UNITS_STD_FMT::format("{:22}", q) + (UNITS_STD_FMT::format(",{:20}", value_cast<Us>(q)) + ...);
|
||||
return MP_UNITS_STD_FMT::format("{:22}", q) + (MP_UNITS_STD_FMT::format(",{:20}", value_cast<Us>(q)) + ...);
|
||||
}
|
||||
|
||||
// Print the ship details in the units as defined in the Ship struct, in other si::imperial units, and in SI
|
||||
void print_details(std::string_view description, const Ship& ship)
|
||||
{
|
||||
const auto waterDensity = 62.4 * isq::density[lb / cubic(ft)];
|
||||
std::cout << UNITS_STD_FMT::format("{}\n", description);
|
||||
std::cout << UNITS_STD_FMT::format("{:20} : {}\n", "length", fmt_line<yd, m>(ship.length))
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "draft", fmt_line<yd, m>(ship.draft))
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "beam", fmt_line<yd, m>(ship.beam))
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "mass", fmt_line<imperial::long_ton, t>(ship.mass))
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "speed", fmt_line<kt, km / h>(ship.speed))
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "power", fmt_line<hp, kW>(ship.power))
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "main guns", fmt_line<in, mm>(ship.mainGuns))
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "fire shells weighing",
|
||||
fmt_line<imperial::long_ton, kg>(ship.shellMass))
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "fire shells at", fmt_line<mph, km / h>(ship.shellSpeed))
|
||||
<< UNITS_STD_FMT::format("{:20} : {}\n", "volume underwater", fmt_line<m3, l>(ship.mass / waterDensity));
|
||||
std::cout << MP_UNITS_STD_FMT::format("{}\n", description);
|
||||
std::cout << MP_UNITS_STD_FMT::format("{:20} : {}\n", "length", fmt_line<yd, m>(ship.length))
|
||||
<< MP_UNITS_STD_FMT::format("{:20} : {}\n", "draft", fmt_line<yd, m>(ship.draft))
|
||||
<< MP_UNITS_STD_FMT::format("{:20} : {}\n", "beam", fmt_line<yd, m>(ship.beam))
|
||||
<< MP_UNITS_STD_FMT::format("{:20} : {}\n", "mass", fmt_line<imperial::long_ton, t>(ship.mass))
|
||||
<< MP_UNITS_STD_FMT::format("{:20} : {}\n", "speed", fmt_line<kt, km / h>(ship.speed))
|
||||
<< MP_UNITS_STD_FMT::format("{:20} : {}\n", "power", fmt_line<hp, kW>(ship.power))
|
||||
<< MP_UNITS_STD_FMT::format("{:20} : {}\n", "main guns", fmt_line<in, mm>(ship.mainGuns))
|
||||
<< MP_UNITS_STD_FMT::format("{:20} : {}\n", "fire shells weighing",
|
||||
fmt_line<imperial::long_ton, kg>(ship.shellMass))
|
||||
<< MP_UNITS_STD_FMT::format("{:20} : {}\n", "fire shells at", fmt_line<mph, km / h>(ship.shellSpeed))
|
||||
<< MP_UNITS_STD_FMT::format("{:20} : {}\n", "volume underwater", fmt_line<m3, l>(ship.mass / waterDensity));
|
||||
}
|
||||
|
||||
int main()
|
||||
|
Reference in New Issue
Block a user