mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
refactor: conversion from quantity
to quantity_point
is now explicit
This commit is contained in:
@@ -78,7 +78,7 @@ quantity<To, Rep> exchange_to(quantity<From, Rep> q)
|
||||
template<ReferenceOf<currency> auto To, ReferenceOf<currency> auto From, auto PO, typename Rep>
|
||||
quantity_point<To, PO, Rep> exchange_to(quantity_point<From, PO, Rep> q)
|
||||
{
|
||||
return static_cast<Rep>(exchange_rate<q.unit, get_unit(To)>() * q.absolute().number()) * To;
|
||||
return quantity_point{static_cast<Rep>(exchange_rate<q.unit, get_unit(To)>() * q.absolute().number()) * To};
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@@ -97,7 +97,7 @@ hae_altitude<M> to_hae(msl_altitude msl, position<long double> pos)
|
||||
{
|
||||
const auto geoid_undulation =
|
||||
isq::height(GeographicLibWhatsMyOffset(pos.lat.number_in(si::degree), pos.lon.number_in(si::degree)) * si::metre);
|
||||
return msl.absolute() - geoid_undulation;
|
||||
return hae_altitude<M>{msl.absolute() - geoid_undulation};
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ struct STD_FMT::formatter<hal_altitude> : formatter<hal_altitude::quantity_type>
|
||||
// **** UAV ****
|
||||
|
||||
class unmanned_aerial_vehicle {
|
||||
msl_altitude current_ = 0 * si::metre;
|
||||
msl_altitude current_{0 * si::metre};
|
||||
msl_altitude launch_ = current_;
|
||||
public:
|
||||
void take_off(msl_altitude alt) { launch_ = alt; }
|
||||
@@ -138,7 +138,7 @@ public:
|
||||
void current(msl_altitude alt) { current_ = alt; }
|
||||
msl_altitude current() const { return current_; }
|
||||
|
||||
hal_altitude hal() const { return current_ - launch_; }
|
||||
hal_altitude hal() const { return hal_altitude{current_ - launch_}; }
|
||||
};
|
||||
|
||||
|
||||
@@ -148,11 +148,11 @@ int main()
|
||||
using namespace mp_units::international::unit_symbols;
|
||||
|
||||
unmanned_aerial_vehicle uav;
|
||||
uav.take_off(6'000 * ft);
|
||||
uav.current(10'000 * ft);
|
||||
uav.take_off(msl_altitude{6'000 * ft});
|
||||
uav.current(msl_altitude{10'000 * ft});
|
||||
std::cout << STD_FMT::format("hal = {}\n", uav.hal());
|
||||
|
||||
msl_altitude ground_level = 123 * m;
|
||||
msl_altitude ground_level{123 * m};
|
||||
std::cout << STD_FMT::format("agl = {}\n", uav.current() - ground_level);
|
||||
|
||||
struct waypoint {
|
||||
|
@@ -102,7 +102,7 @@ public:
|
||||
|
||||
template<typename T>
|
||||
requires std::constructible_from<quantity_type, T>
|
||||
constexpr explicit(!std::convertible_to<T, quantity_type>) quantity_point(T&& v) : q_(std::forward<T>(v))
|
||||
constexpr explicit quantity_point(T&& v) : q_(std::forward<T>(v))
|
||||
{
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user