mirror of
https://github.com/mpusz/mp-units.git
synced 2025-06-25 01:01:33 +02:00
quantity_cast<U, Rep> support added
This commit is contained in:
@ -46,7 +46,7 @@ void example_2(double distance_v, double duration_v)
|
||||
{
|
||||
stde::units::quantity<stde::units::kilometre> distance(distance_v);
|
||||
stde::units::quantity<stde::units::hour> duration(duration_v);
|
||||
const auto kmph = avg_speed(distance, duration);
|
||||
const auto kmph = quantity_cast<stde::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";
|
||||
}
|
||||
|
@ -135,6 +135,13 @@ namespace std::experimental::units {
|
||||
return cast::cast(q);
|
||||
}
|
||||
|
||||
template<Unit ToU, Scalar ToRep = double, typename U, typename Rep>
|
||||
constexpr quantity<ToU, ToRep> quantity_cast(const quantity<U, Rep>& q)
|
||||
{
|
||||
return quantity_cast<quantity<ToU, ToRep>>(q);
|
||||
}
|
||||
|
||||
|
||||
// quantity_values
|
||||
|
||||
template<Scalar Rep>
|
||||
|
Reference in New Issue
Block a user