refactor: number() and number_in() renamed to value() and value_in()

Resolves #423
This commit is contained in:
Mateusz Pusz
2023-08-23 17:15:32 +02:00
parent ae92b49775
commit a9204e2473
21 changed files with 349 additions and 351 deletions
+3 -3
View File
@@ -33,7 +33,7 @@ template<mp_units::Quantity Target, mp_units::Quantity Source>
requires std::constructible_from<Target, Source>
inline constexpr double conversion_factor(Target, Source)
{
return mp_units::value_cast<Target::unit>(1. * Source::reference).number();
return mp_units::value_cast<Target::unit>(1. * Source::reference).value();
}
} // namespace
@@ -55,6 +55,6 @@ int main()
std::cout << MP_UNITS_STD_FMT::format("conversion factor from lengthA::unit of {:%q} to lengthB::unit of {:%q}:\n\n",
lengthA, lengthB)
<< MP_UNITS_STD_FMT::format("lengthB.number( {} ) == lengthA.number( {} ) * conversion_factor( {} )\n",
lengthB.number(), lengthA.number(), conversion_factor(lengthB, lengthA));
<< MP_UNITS_STD_FMT::format("lengthB.value( {} ) == lengthA.value( {} ) * conversion_factor( {} )\n",
lengthB.value(), lengthA.value(), conversion_factor(lengthB, lengthA));
}
+2 -2
View File
@@ -75,14 +75,14 @@ template<Unit auto From, Unit auto To>
template<ReferenceOf<currency> auto To, ReferenceOf<currency> auto From, typename Rep>
quantity<To, Rep> exchange_to(quantity<From, Rep> q)
{
return static_cast<Rep>(exchange_rate<q.unit, get_unit(To)>() * q.number()) * To;
return static_cast<Rep>(exchange_rate<q.unit, get_unit(To)>() * q.value()) * To;
}
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 quantity_point{
zero + static_cast<Rep>(exchange_rate<q.unit, get_unit(To)>() * (q - q.absolute_point_origin).number()) * To};
zero + static_cast<Rep>(exchange_rate<q.unit, get_unit(To)>() * (q - q.absolute_point_origin).value()) * To};
}
int main()
+8 -8
View File
@@ -74,19 +74,19 @@ using longitude =
template<class CharT, class Traits, typename T>
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const latitude<T>& lat)
{
if (lat.number() > 0)
return os << "N" << lat.number();
if (lat.value() > 0)
return os << "N" << lat.value();
else
return os << "S" << -lat.number();
return os << "S" << -lat.value();
}
template<class CharT, class Traits, typename T>
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const longitude<T>& lon)
{
if (lon.number() > 0)
return os << "E" << lon.number();
if (lon.value() > 0)
return os << "E" << lon.value();
else
return os << "W" << -lon.number();
return os << "W" << -lon.value();
}
inline namespace literals {
@@ -129,7 +129,7 @@ struct MP_UNITS_STD_FMT::formatter<geographic::latitude<T>> : formatter<T> {
auto format(geographic::latitude<T> lat, FormatContext& ctx)
{
MP_UNITS_STD_FMT::format_to(ctx.out(), "{}", lat > geographic::latitude<T>::zero() ? 'N' : 'S');
return formatter<T>::format(lat > geographic::latitude<T>::zero() ? lat.number() : -lat.number(), ctx);
return formatter<T>::format(lat > geographic::latitude<T>::zero() ? lat.value() : -lat.value(), ctx);
}
};
@@ -139,7 +139,7 @@ struct MP_UNITS_STD_FMT::formatter<geographic::longitude<T>> : formatter<T> {
auto format(geographic::longitude<T> lon, FormatContext& ctx)
{
MP_UNITS_STD_FMT::format_to(ctx.out(), "{}", lon > geographic::longitude<T>::zero() ? 'E' : 'W');
return formatter<T>::format(lon > geographic::longitude<T>::zero() ? lon.number() : -lon.number(), ctx);
return formatter<T>::format(lon > geographic::longitude<T>::zero() ? lon.value() : -lon.value(), ctx);
}
};
+1 -1
View File
@@ -97,7 +97,7 @@ template<earth_gravity_model M>
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);
isq::height(GeographicLibWhatsMyOffset(pos.lat.value_in(si::degree), pos.lon.value_in(si::degree)) * si::metre);
return height_above_ellipsoid<M> + (msl - mean_sea_level - geoid_undulation);
}