xo-unit: streamline: rename namespacesu -> u
This commit is contained in:
parent
2c3638d394
commit
22dbb5e529
10 changed files with 131 additions and 126 deletions
|
|
@ -253,7 +253,7 @@ namespace xo {
|
|||
* static_cast<r_repr_type>(x.scale())
|
||||
* static_cast<r_repr_type>(y.scale()));
|
||||
|
||||
return quantity<detail::make_unit_rescale_result<r_int_type>(rr.natural_unit_),
|
||||
return quantity<detail::su_promote<r_int_type>(rr.natural_unit_),
|
||||
r_repr_type>(r_scale);
|
||||
}
|
||||
|
||||
|
|
@ -280,7 +280,7 @@ namespace xo {
|
|||
* static_cast<r_repr_type>(x.scale())
|
||||
/ static_cast<r_repr_type>(y.scale()));
|
||||
|
||||
return quantity<detail::make_unit_rescale_result<r_int_type>(rr.natural_unit_),
|
||||
return quantity<detail::su_promote<r_int_type>(rr.natural_unit_),
|
||||
r_repr_type>(r_scale);
|
||||
}
|
||||
|
||||
|
|
@ -427,28 +427,28 @@ namespace xo {
|
|||
// ----- mass -----
|
||||
|
||||
template <typename Repr>
|
||||
inline constexpr auto picograms(Repr x) { return quantity<su::picogram, Repr>(x); }
|
||||
inline constexpr auto picograms(Repr x) { return quantity<u::picogram, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto nanograms(Repr x) { return quantity<su::nanogram, Repr>(x); }
|
||||
inline constexpr auto nanograms(Repr x) { return quantity<u::nanogram, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto micrograms(Repr x) { return quantity<su::microgram, Repr>(x); }
|
||||
inline constexpr auto micrograms(Repr x) { return quantity<u::microgram, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto milligrams(Repr x) { return quantity<su::milligram, Repr>(x); }
|
||||
inline constexpr auto milligrams(Repr x) { return quantity<u::milligram, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto grams(Repr x) { return quantity<su::gram, Repr>(x); }
|
||||
inline constexpr auto grams(Repr x) { return quantity<u::gram, Repr>(x); }
|
||||
|
||||
/** @brief create a quantity representing @p x kilograms of mass, with compile-time unit representation **/
|
||||
template <typename Repr>
|
||||
inline constexpr auto kilograms(Repr x) { return quantity<su::kilogram, Repr>(x); }
|
||||
inline constexpr auto kilograms(Repr x) { return quantity<u::kilogram, Repr>(x); }
|
||||
|
||||
template <typename Repr>
|
||||
inline constexpr auto tonnes(Repr x) { return quantity<su::tonne, Repr>(x); }
|
||||
inline constexpr auto tonnes(Repr x) { return quantity<u::tonne, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto kilotonnes(Repr x) { return quantity<su::kilotonne, Repr>(x); }
|
||||
inline constexpr auto kilotonnes(Repr x) { return quantity<u::kilotonne, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto megatonnes(Repr x) { return quantity<su::megatonne, Repr>(x); }
|
||||
inline constexpr auto megatonnes(Repr x) { return quantity<u::megatonne, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto gigatonnes(Repr x) { return quantity<su::gigatonne, Repr>(x); }
|
||||
inline constexpr auto gigatonnes(Repr x) { return quantity<u::gigatonne, Repr>(x); }
|
||||
|
||||
/** @brief a quantity representing 1 picogram of mass, with compile-time unit representation **/
|
||||
static constexpr auto picogram = picograms(1);
|
||||
|
|
@ -472,39 +472,39 @@ namespace xo {
|
|||
// ----- distance -----
|
||||
|
||||
template <typename Repr>
|
||||
inline constexpr auto picometers(Repr x) { return quantity<su::picometer, Repr>(x); }
|
||||
inline constexpr auto picometers(Repr x) { return quantity<u::picometer, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto nanometers(Repr x) { return quantity<su::nanometer, Repr>(x); }
|
||||
inline constexpr auto nanometers(Repr x) { return quantity<u::nanometer, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto micrometers(Repr x) { return quantity<su::micrometer, Repr>(x); }
|
||||
inline constexpr auto micrometers(Repr x) { return quantity<u::micrometer, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto millimeters(Repr x) { return quantity<su::millimeter, Repr>(x); }
|
||||
inline constexpr auto millimeters(Repr x) { return quantity<u::millimeter, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto meters(Repr x) { return quantity<su::meter, Repr>(x); }
|
||||
inline constexpr auto meters(Repr x) { return quantity<u::meter, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto kilometers(Repr x) { return quantity<su::kilometer, Repr>(x); }
|
||||
inline constexpr auto kilometers(Repr x) { return quantity<u::kilometer, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto megameters(Repr x) { return quantity<su::megameter, Repr>(x); }
|
||||
inline constexpr auto megameters(Repr x) { return quantity<u::megameter, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto gigameters(Repr x) { return quantity<su::gigameter, Repr>(x); }
|
||||
inline constexpr auto gigameters(Repr x) { return quantity<u::gigameter, Repr>(x); }
|
||||
|
||||
template <typename Repr>
|
||||
inline constexpr auto lightseconds(Repr x) { return quantity<su::lightsecond, Repr>(x); }
|
||||
inline constexpr auto lightseconds(Repr x) { return quantity<u::lightsecond, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto astronomicalunits(Repr x) { return quantity<su::astronomicalunit, Repr>(x); }
|
||||
inline constexpr auto astronomicalunits(Repr x) { return quantity<u::astronomicalunit, Repr>(x); }
|
||||
|
||||
/** @brief create quantity representing @p x inches of distance, with compile-time unit representation **/
|
||||
template <typename Repr>
|
||||
inline constexpr auto inches(Repr x) { return quantity<su::inch, Repr>(x); }
|
||||
inline constexpr auto inches(Repr x) { return quantity<u::inch, Repr>(x); }
|
||||
/** @brief create quantity representing @p x feet of distance, with compile-time unit representation **/
|
||||
template <typename Repr>
|
||||
inline constexpr auto feet(Repr x) { return quantity<su::foot, Repr>(x); }
|
||||
inline constexpr auto feet(Repr x) { return quantity<u::foot, Repr>(x); }
|
||||
/** @brief create quantity representing @p x yards of distance, with compile-time unit representation **/
|
||||
template <typename Repr>
|
||||
inline constexpr auto yards(Repr x) { return quantity<su::yard, Repr>(x); }
|
||||
inline constexpr auto yards(Repr x) { return quantity<u::yard, Repr>(x); }
|
||||
/** @brief create quantity representing @p x statute miles of distance, with compile-time unit representation **/
|
||||
template <typename Repr>
|
||||
inline constexpr auto miles(Repr x) { return quantity<su::mile, Repr>(x); }
|
||||
inline constexpr auto miles(Repr x) { return quantity<u::mile, Repr>(x); }
|
||||
|
||||
/** @brief a quantity representing 1 picometer of distance, with compile-time unit representation **/
|
||||
static constexpr auto picometer = picometers(1);
|
||||
|
|
@ -534,44 +534,44 @@ namespace xo {
|
|||
// ----- time -----
|
||||
|
||||
template <typename Repr>
|
||||
inline constexpr auto picoseconds(Repr x) { return quantity<su::picosecond, Repr>(x); }
|
||||
inline constexpr auto picoseconds(Repr x) { return quantity<u::picosecond, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto nanoseconds(Repr x) { return quantity<su::nanosecond, Repr>(x); }
|
||||
inline constexpr auto nanoseconds(Repr x) { return quantity<u::nanosecond, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto microseconds(Repr x) { return quantity<su::microsecond, Repr>(x); }
|
||||
inline constexpr auto microseconds(Repr x) { return quantity<u::microsecond, Repr>(x); }
|
||||
|
||||
template <typename Repr>
|
||||
inline constexpr auto milliseconds(Repr x) { return quantity<su::millisecond, Repr>(x); }
|
||||
inline constexpr auto milliseconds(Repr x) { return quantity<u::millisecond, Repr>(x); }
|
||||
|
||||
/** @brief create quantity representing @p x seconds of time, with compile-time unit representation **/
|
||||
template <typename Repr>
|
||||
|
||||
inline constexpr auto seconds(Repr x) { return quantity<su::second, Repr>(x); }
|
||||
inline constexpr auto seconds(Repr x) { return quantity<u::second, Repr>(x); }
|
||||
|
||||
/** @brief create quantity representing @p x minutes of time, with compile-time unit representation **/
|
||||
template <typename Repr>
|
||||
inline constexpr auto minutes(Repr x) { return quantity<su::minute, Repr>(x); }
|
||||
inline constexpr auto minutes(Repr x) { return quantity<u::minute, Repr>(x); }
|
||||
|
||||
/** @brief create quantity representing @p x hours of time, with compile-time unit representation **/
|
||||
template <typename Repr>
|
||||
inline constexpr auto hours(Repr x) { return quantity<su::hour, Repr>(x); }
|
||||
inline constexpr auto hours(Repr x) { return quantity<u::hour, Repr>(x); }
|
||||
|
||||
/** @brief create quantity representing @p x days of time, with compile-time unit representation **/
|
||||
template <typename Repr>
|
||||
inline constexpr auto days(Repr x) { return quantity<su::day, Repr>(x); }
|
||||
inline constexpr auto days(Repr x) { return quantity<u::day, Repr>(x); }
|
||||
|
||||
template <typename Repr>
|
||||
inline constexpr auto weeks(Repr x) { return quantity<su::week, Repr>(x); }
|
||||
inline constexpr auto weeks(Repr x) { return quantity<u::week, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto months(Repr x) { return quantity<su::month, Repr>(x); }
|
||||
inline constexpr auto months(Repr x) { return quantity<u::month, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto years(Repr x) { return quantity<su::year, Repr>(x); }
|
||||
inline constexpr auto years(Repr x) { return quantity<u::year, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto year250s(Repr x) { return quantity<su::year250, Repr>(x); }
|
||||
inline constexpr auto year250s(Repr x) { return quantity<u::year250, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto year360s(Repr x) { return quantity<su::year360, Repr>(x); }
|
||||
inline constexpr auto year360s(Repr x) { return quantity<u::year360, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto year365s(Repr x) { return quantity<su::year365, Repr>(x); }
|
||||
inline constexpr auto year365s(Repr x) { return quantity<u::year365, Repr>(x); }
|
||||
|
||||
/** @brief a quantity representing 1 second of time, with compile-time unit representation **/
|
||||
static constexpr auto second = seconds(1);
|
||||
|
|
@ -591,13 +591,13 @@ namespace xo {
|
|||
*/
|
||||
|
||||
template <typename Repr>
|
||||
inline constexpr auto volatility_30d(Repr x) { return quantity<su::volatility_30d, Repr>(x); }
|
||||
inline constexpr auto volatility_30d(Repr x) { return quantity<u::volatility_30d, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto volatility_250d(Repr x) { return quantity<su::volatility_250d, Repr>(x); }
|
||||
inline constexpr auto volatility_250d(Repr x) { return quantity<u::volatility_250d, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto volatility_360d(Repr x) { return quantity<su::volatility_360d, Repr>(x); }
|
||||
inline constexpr auto volatility_360d(Repr x) { return quantity<u::volatility_360d, Repr>(x); }
|
||||
template <typename Repr>
|
||||
inline constexpr auto volatility_365d(Repr x) { return quantity<su::volatility_365d, Repr>(x); }
|
||||
inline constexpr auto volatility_365d(Repr x) { return quantity<u::volatility_365d, Repr>(x); }
|
||||
} /*namespace qty*/
|
||||
|
||||
/* reminder: see [quantity_ops.hpp] for operator* etc */
|
||||
|
|
|
|||
|
|
@ -56,61 +56,67 @@ namespace xo {
|
|||
|
||||
namespace detail {
|
||||
template <typename Int>
|
||||
constexpr auto make_unit_rescale_result(const natural_unit<Int> & bpuv) {
|
||||
constexpr auto su_promote(const natural_unit<Int> & bpuv) {
|
||||
return scaled_unit<Int>(bpuv,
|
||||
ratio::ratio<Int>(1, 1),
|
||||
1.0);
|
||||
}
|
||||
}
|
||||
|
||||
namespace su {
|
||||
constexpr auto picogram = detail::make_unit_rescale_result<std::int64_t>(nu::picogram);
|
||||
constexpr auto nanogram = detail::make_unit_rescale_result<std::int64_t>(nu::nanogram);
|
||||
constexpr auto microgram = detail::make_unit_rescale_result<std::int64_t>(nu::microgram);
|
||||
constexpr auto milligram = detail::make_unit_rescale_result<std::int64_t>(nu::milligram);
|
||||
constexpr auto gram = detail::make_unit_rescale_result<std::int64_t>(nu::gram);
|
||||
constexpr auto kilogram = detail::make_unit_rescale_result<std::int64_t>(nu::kilogram);
|
||||
constexpr auto tonne = detail::make_unit_rescale_result<std::int64_t>(nu::tonne);
|
||||
constexpr auto kilotonne = detail::make_unit_rescale_result<std::int64_t>(nu::kilotonne);
|
||||
constexpr auto megatonne = detail::make_unit_rescale_result<std::int64_t>(nu::megatonne);
|
||||
constexpr auto gigatonne = detail::make_unit_rescale_result<std::int64_t>(nu::gigatonne);
|
||||
namespace u {
|
||||
/* values here can be used as template arguments to quantity:
|
||||
* e.g.
|
||||
* quantity<u:picogram> qty1;
|
||||
* quantity<u:meter/u:second> velocity;
|
||||
*/
|
||||
|
||||
constexpr auto picometer = detail::make_unit_rescale_result<std::int64_t>(nu::picometer);
|
||||
constexpr auto nanometer = detail::make_unit_rescale_result<std::int64_t>(nu::nanometer);
|
||||
constexpr auto micrometer = detail::make_unit_rescale_result<std::int64_t>(nu::micrometer);
|
||||
constexpr auto millimeter = detail::make_unit_rescale_result<std::int64_t>(nu::millimeter);
|
||||
constexpr auto meter = detail::make_unit_rescale_result<std::int64_t>(nu::meter);
|
||||
constexpr auto kilometer = detail::make_unit_rescale_result<std::int64_t>(nu::kilometer);
|
||||
constexpr auto megameter = detail::make_unit_rescale_result<std::int64_t>(nu::megameter);
|
||||
constexpr auto gigameter = detail::make_unit_rescale_result<std::int64_t>(nu::gigameter);
|
||||
constexpr auto picogram = detail::su_promote<std::int64_t>(nu::picogram);
|
||||
constexpr auto nanogram = detail::su_promote<std::int64_t>(nu::nanogram);
|
||||
constexpr auto microgram = detail::su_promote<std::int64_t>(nu::microgram);
|
||||
constexpr auto milligram = detail::su_promote<std::int64_t>(nu::milligram);
|
||||
constexpr auto gram = detail::su_promote<std::int64_t>(nu::gram);
|
||||
constexpr auto kilogram = detail::su_promote<std::int64_t>(nu::kilogram);
|
||||
constexpr auto tonne = detail::su_promote<std::int64_t>(nu::tonne);
|
||||
constexpr auto kilotonne = detail::su_promote<std::int64_t>(nu::kilotonne);
|
||||
constexpr auto megatonne = detail::su_promote<std::int64_t>(nu::megatonne);
|
||||
constexpr auto gigatonne = detail::su_promote<std::int64_t>(nu::gigatonne);
|
||||
|
||||
constexpr auto lightsecond = detail::make_unit_rescale_result<std::int64_t>(nu::lightsecond);
|
||||
constexpr auto astronomicalunit = detail::make_unit_rescale_result<std::int64_t>(nu::astronomicalunit);
|
||||
constexpr auto picometer = detail::su_promote<std::int64_t>(nu::picometer);
|
||||
constexpr auto nanometer = detail::su_promote<std::int64_t>(nu::nanometer);
|
||||
constexpr auto micrometer = detail::su_promote<std::int64_t>(nu::micrometer);
|
||||
constexpr auto millimeter = detail::su_promote<std::int64_t>(nu::millimeter);
|
||||
constexpr auto meter = detail::su_promote<std::int64_t>(nu::meter);
|
||||
constexpr auto kilometer = detail::su_promote<std::int64_t>(nu::kilometer);
|
||||
constexpr auto megameter = detail::su_promote<std::int64_t>(nu::megameter);
|
||||
constexpr auto gigameter = detail::su_promote<std::int64_t>(nu::gigameter);
|
||||
|
||||
constexpr auto inch = detail::make_unit_rescale_result<std::int64_t>(nu::inch);
|
||||
constexpr auto foot = detail::make_unit_rescale_result<std::int64_t>(nu::foot);
|
||||
constexpr auto yard = detail::make_unit_rescale_result<std::int64_t>(nu::yard);
|
||||
constexpr auto mile = detail::make_unit_rescale_result<std::int64_t>(nu::mile);
|
||||
constexpr auto lightsecond = detail::su_promote<std::int64_t>(nu::lightsecond);
|
||||
constexpr auto astronomicalunit = detail::su_promote<std::int64_t>(nu::astronomicalunit);
|
||||
|
||||
constexpr auto picosecond = detail::make_unit_rescale_result<std::int64_t>(nu::picosecond);
|
||||
constexpr auto nanosecond = detail::make_unit_rescale_result<std::int64_t>(nu::nanosecond);
|
||||
constexpr auto microsecond = detail::make_unit_rescale_result<std::int64_t>(nu::microsecond);
|
||||
constexpr auto millisecond = detail::make_unit_rescale_result<std::int64_t>(nu::millisecond);
|
||||
constexpr auto second = detail::make_unit_rescale_result<std::int64_t>(nu::second);
|
||||
constexpr auto minute = detail::make_unit_rescale_result<std::int64_t>(nu::minute);
|
||||
constexpr auto hour = detail::make_unit_rescale_result<std::int64_t>(nu::hour);
|
||||
constexpr auto day = detail::make_unit_rescale_result<std::int64_t>(nu::day);
|
||||
constexpr auto week = detail::make_unit_rescale_result<std::int64_t>(nu::week);
|
||||
constexpr auto month = detail::make_unit_rescale_result<std::int64_t>(nu::month);
|
||||
constexpr auto year = detail::make_unit_rescale_result<std::int64_t>(nu::year);
|
||||
constexpr auto year250 = detail::make_unit_rescale_result<std::int64_t>(nu::year250);
|
||||
constexpr auto year360 = detail::make_unit_rescale_result<std::int64_t>(nu::year360);
|
||||
constexpr auto year365 = detail::make_unit_rescale_result<std::int64_t>(nu::year365);
|
||||
constexpr auto inch = detail::su_promote<std::int64_t>(nu::inch);
|
||||
constexpr auto foot = detail::su_promote<std::int64_t>(nu::foot);
|
||||
constexpr auto yard = detail::su_promote<std::int64_t>(nu::yard);
|
||||
constexpr auto mile = detail::su_promote<std::int64_t>(nu::mile);
|
||||
|
||||
constexpr auto volatility_30d = detail::make_unit_rescale_result<std::int64_t>(nu::volatility_30d);
|
||||
constexpr auto volatility_250d = detail::make_unit_rescale_result<std::int64_t>(nu::volatility_250d);
|
||||
constexpr auto volatility_360d = detail::make_unit_rescale_result<std::int64_t>(nu::volatility_360d);
|
||||
constexpr auto volatility_365d = detail::make_unit_rescale_result<std::int64_t>(nu::volatility_365d);
|
||||
constexpr auto picosecond = detail::su_promote<std::int64_t>(nu::picosecond);
|
||||
constexpr auto nanosecond = detail::su_promote<std::int64_t>(nu::nanosecond);
|
||||
constexpr auto microsecond = detail::su_promote<std::int64_t>(nu::microsecond);
|
||||
constexpr auto millisecond = detail::su_promote<std::int64_t>(nu::millisecond);
|
||||
constexpr auto second = detail::su_promote<std::int64_t>(nu::second);
|
||||
constexpr auto minute = detail::su_promote<std::int64_t>(nu::minute);
|
||||
constexpr auto hour = detail::su_promote<std::int64_t>(nu::hour);
|
||||
constexpr auto day = detail::su_promote<std::int64_t>(nu::day);
|
||||
constexpr auto week = detail::su_promote<std::int64_t>(nu::week);
|
||||
constexpr auto month = detail::su_promote<std::int64_t>(nu::month);
|
||||
constexpr auto year = detail::su_promote<std::int64_t>(nu::year);
|
||||
constexpr auto year250 = detail::su_promote<std::int64_t>(nu::year250);
|
||||
constexpr auto year360 = detail::su_promote<std::int64_t>(nu::year360);
|
||||
constexpr auto year365 = detail::su_promote<std::int64_t>(nu::year365);
|
||||
|
||||
constexpr auto volatility_30d = detail::su_promote<std::int64_t>(nu::volatility_30d);
|
||||
constexpr auto volatility_250d = detail::su_promote<std::int64_t>(nu::volatility_250d);
|
||||
constexpr auto volatility_360d = detail::su_promote<std::int64_t>(nu::volatility_360d);
|
||||
constexpr auto volatility_365d = detail::su_promote<std::int64_t>(nu::volatility_365d);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue