mirror of
https://github.com/mpusz/mp-units.git
synced 2025-06-25 01:01:33 +02:00
Example and test package code changed to use text formatting
This commit is contained in:
@ -37,8 +37,8 @@ template<units::Velocity V, units::Time T>
|
||||
void example_1(V v, T t)
|
||||
{
|
||||
const units::Length AUTO distance = v * t;
|
||||
std::cout << "A car driving " << v.count() << " km/h in a time of " << t.count() << " minutes will pass "
|
||||
<< units::quantity_cast<units::quantity<units::metre, double>>(distance).count() << " metres.\n";
|
||||
std::cout << "A car driving " << v << " in a time of " << t << " will pass "
|
||||
<< units::quantity_cast<units::quantity<units::metre, double>>(distance) << ".\n";
|
||||
}
|
||||
|
||||
void example_2(double distance_v, double duration_v)
|
||||
@ -46,8 +46,8 @@ void example_2(double distance_v, double duration_v)
|
||||
units::quantity<units::kilometre> distance(distance_v);
|
||||
units::quantity<units::hour> duration(duration_v);
|
||||
const auto kmph = quantity_cast<units::kilometre_per_hour>(avg_speed(distance, duration));
|
||||
std::cout << "Average speed of a car that makes " << distance.count() << " km in "
|
||||
<< duration.count() << " hours is " << kmph.count() << " km/h.\n";
|
||||
std::cout << "Average speed of a car that makes " << distance << " in "
|
||||
<< duration << " is " << kmph << ".\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,5 +33,5 @@ constexpr units::Velocity avg_speed(D d, T t)
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Average speed = " << avg_speed(240.0km, 2h).count() << " kmph\n";
|
||||
std::cout << "Average speed = " << avg_speed(240.km, 2h) << '\n';
|
||||
}
|
||||
|
Reference in New Issue
Block a user