xo-unit: streamline: rename namespacesu -> u
This commit is contained in:
parent
2c3638d394
commit
22dbb5e529
10 changed files with 131 additions and 126 deletions
|
|
@ -7,7 +7,7 @@
|
|||
int
|
||||
main () {
|
||||
namespace q = xo::qty::qty;
|
||||
namespace su = xo::qty::su;
|
||||
namespace u = xo::qty::u;
|
||||
using xo::qty::quantity;
|
||||
using xo::flatstring;
|
||||
using namespace std;
|
||||
|
|
@ -43,7 +43,7 @@ main () {
|
|||
static_assert(a.scale() == 0.625);
|
||||
static_assert(a.abbrev() == flatstring("km.min^-2"));
|
||||
|
||||
constexpr auto a2 = a.rescale_ext<(su::meter / (su::second * su::second))>();
|
||||
constexpr auto a2 = a.rescale_ext<(u::meter / (u::second * u::second))>();
|
||||
|
||||
cerr << "d.t^-2: " << a2 << endl;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
int
|
||||
main () {
|
||||
namespace q = xo::qty::qty;
|
||||
namespace su = xo::qty::su;
|
||||
namespace u = xo::qty::u;
|
||||
using xo::qty::with_units_from;
|
||||
using xo::qty::with_units;
|
||||
using xo::qty::quantity;
|
||||
|
|
@ -25,13 +25,13 @@ main () {
|
|||
<< ", d.t^-2: " << a
|
||||
<< endl;
|
||||
|
||||
constexpr auto a2 = a.rescale_ext<su::meter / (su::second * su::second)>();
|
||||
constexpr auto a2 = a.rescale_ext<u::meter / (u::second * u::second)>();
|
||||
|
||||
static_assert(a2.abbrev() == flatstring("m.s^-2"));
|
||||
|
||||
cerr << "a2: " << a2 << endl;
|
||||
|
||||
constexpr auto a3 = with_units<su::meter / (su::second * su::second)>(a);
|
||||
constexpr auto a3 = with_units<u::meter / (u::second * u::second)>(a);
|
||||
|
||||
static_assert(a3.abbrev() == flatstring("m.s^-2"));
|
||||
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@
|
|||
int
|
||||
main () {
|
||||
namespace q = xo::qty::qty;
|
||||
namespace su = xo::qty::su;
|
||||
namespace u = xo::qty::u;
|
||||
//namespace nu = xo::qty::nu;
|
||||
using xo::qty::quantity;
|
||||
using xo::flatstring;
|
||||
using namespace std;
|
||||
|
||||
constexpr quantity<su::second> t = q::minutes(2);
|
||||
constexpr quantity<su::meter> d = q::kilometers(2.5);
|
||||
constexpr quantity<u::second> t = q::minutes(2);
|
||||
constexpr quantity<u::meter> d = q::kilometers(2.5);
|
||||
|
||||
constexpr auto t2 = t*t;
|
||||
constexpr auto a = d / (t*t);
|
||||
|
|
|
|||
|
|
@ -6,9 +6,8 @@
|
|||
|
||||
int
|
||||
main () {
|
||||
//namespace u = xo::unit::units;
|
||||
using namespace xo::qty;
|
||||
//namespace su = xo::qty::su;
|
||||
namespace u = xo::qty::u;
|
||||
namespace q = xo::qty::qty;
|
||||
using namespace std;
|
||||
|
||||
|
|
@ -23,7 +22,7 @@ main () {
|
|||
/* rescale to not-so-absurd units */
|
||||
|
||||
/* kg.m.s^-2 */
|
||||
quantity res = qty3.rescale_ext<su::kilogram * su::meter / (su::second * su::second)>();
|
||||
quantity res = qty3.rescale_ext<u::kilogram * u::meter / (u::second * u::second)>();
|
||||
|
||||
/* 2.57958e-10kg.m.s^-2 */
|
||||
cerr << "res: " << res << endl;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -389,7 +389,7 @@ namespace xo {
|
|||
static_assert(rr.outer_scale_factor_.template convert_to<decltype(ms)::repr_type>() == 1.0);
|
||||
static_assert(rr.natural_unit_.n_bpu() == 1);
|
||||
|
||||
constexpr auto q1 = quantity<detail::make_unit_rescale_result<decltype(ms)::ratio_int_type>(rr.natural_unit_),
|
||||
constexpr auto q1 = quantity<detail::su_promote<decltype(ms)::ratio_int_type>(rr.natural_unit_),
|
||||
decltype(ms)::repr_type>(ms.scale() * ms.scale());
|
||||
|
||||
/* proof that q is constexpr */
|
||||
|
|
@ -461,7 +461,7 @@ namespace xo {
|
|||
static_assert(rr.outer_scale_factor_.template convert_to<decltype(ms)::repr_type>() == 1.0);
|
||||
static_assert(rr.natural_unit_.n_bpu() == 0);
|
||||
|
||||
constexpr auto q1 = quantity<detail::make_unit_rescale_result<decltype(ms)::ratio_int_type>(rr.natural_unit_),
|
||||
constexpr auto q1 = quantity<detail::su_promote<decltype(ms)::ratio_int_type>(rr.natural_unit_),
|
||||
decltype(ms)::repr_type>(ms.scale() * ms.scale());
|
||||
|
||||
/* proof that q is constexpr */
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ namespace xo {
|
|||
|
||||
scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.scaled_unit0"));
|
||||
|
||||
constexpr auto ng = su::nanogram;
|
||||
constexpr auto ng = u::nanogram;
|
||||
constexpr auto ng2 = ng * ng;
|
||||
|
||||
log && log(xtag("ng", ng));
|
||||
|
|
@ -90,7 +90,7 @@ namespace xo {
|
|||
|
||||
scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.scaled_unit1"));
|
||||
|
||||
constexpr auto ng = su::nanogram;
|
||||
constexpr auto ng = u::nanogram;
|
||||
constexpr auto ng2 = ng / ng;
|
||||
|
||||
log && log(xtag("ng", ng));
|
||||
|
|
@ -105,7 +105,7 @@ namespace xo {
|
|||
|
||||
scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.scaled_unit2"));
|
||||
|
||||
constexpr auto ms = su::millisecond;
|
||||
constexpr auto ms = u::millisecond;
|
||||
constexpr auto ms2 = ms * ms;
|
||||
|
||||
log && log(xtag("ms", ms));
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace xo {
|
|||
namespace ut {
|
||||
/* compile-time tests */
|
||||
|
||||
namespace su = xo::qty::su;
|
||||
namespace u = xo::qty::u;
|
||||
|
||||
using xo::qty::dim;
|
||||
using xo::qty::basis_unit2_abbrev_type;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include <string>
|
||||
|
||||
namespace xo {
|
||||
namespace su = xo::qty::su;
|
||||
namespace u = xo::qty::u;
|
||||
namespace nu = xo::qty::nu;
|
||||
|
||||
using xo::qty::xquantity;
|
||||
|
|
@ -388,7 +388,7 @@ namespace xo {
|
|||
scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.xquantity"));
|
||||
|
||||
/* not constexpr until c++26 */
|
||||
auto ng = unit_qty(su::nanogram);
|
||||
auto ng = unit_qty(u::nanogram);
|
||||
|
||||
log && log(xtag("ng", ng));
|
||||
|
||||
|
|
@ -401,7 +401,7 @@ namespace xo {
|
|||
scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.xquantity2"));
|
||||
|
||||
/* not constexpr until c++26 */
|
||||
xquantity ng = unit_qty(su::nanogram);
|
||||
xquantity ng = unit_qty(u::nanogram);
|
||||
auto ng2 = ng * ng;
|
||||
|
||||
log && log(xtag("ng*ng", ng2));
|
||||
|
|
@ -415,7 +415,7 @@ namespace xo {
|
|||
scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.xquantity3"));
|
||||
|
||||
/* not constexpr until c++26 */
|
||||
xquantity ng = unit_qty(su::nanogram);
|
||||
xquantity ng = unit_qty(u::nanogram);
|
||||
auto ng0 = ng / ng;
|
||||
|
||||
log && log(xtag("ng/ng", ng0));
|
||||
|
|
@ -429,8 +429,8 @@ namespace xo {
|
|||
scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.xquantity4"));
|
||||
|
||||
/* not constexpr until c++26 */
|
||||
xquantity ng = unit_qty(su::nanogram);
|
||||
xquantity ug = unit_qty(su::microgram);
|
||||
xquantity ng = unit_qty(u::nanogram);
|
||||
xquantity ug = unit_qty(u::microgram);
|
||||
|
||||
{
|
||||
auto prod1 = ng * ug;
|
||||
|
|
@ -465,8 +465,8 @@ namespace xo {
|
|||
scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.xquantity5"));
|
||||
|
||||
/* not constexpr until c++26 */
|
||||
xquantity ng = unit_qty(su::nanogram);
|
||||
xquantity ug = unit_qty(su::microgram);
|
||||
xquantity ng = unit_qty(u::nanogram);
|
||||
xquantity ug = unit_qty(u::microgram);
|
||||
|
||||
{
|
||||
auto ratio1 = ng / ug;
|
||||
|
|
@ -494,8 +494,8 @@ namespace xo {
|
|||
scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.xquantity6"));
|
||||
|
||||
/* not constexpr until c++26 */
|
||||
xquantity ng = unit_qty(su::nanogram);
|
||||
xquantity ug = unit_qty(su::microgram);
|
||||
xquantity ng = unit_qty(u::nanogram);
|
||||
xquantity ug = unit_qty(u::microgram);
|
||||
|
||||
{
|
||||
auto sum1 = ng + ug;
|
||||
|
|
@ -526,8 +526,8 @@ namespace xo {
|
|||
scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.xquantity7"));
|
||||
|
||||
/* not constexpr until c++26 */
|
||||
xquantity ng = unit_qty(su::nanogram);
|
||||
xquantity ug = unit_qty(su::microgram);
|
||||
xquantity ng = unit_qty(u::nanogram);
|
||||
xquantity ug = unit_qty(u::microgram);
|
||||
|
||||
{
|
||||
auto sum1 = ng - ug;
|
||||
|
|
@ -558,8 +558,8 @@ namespace xo {
|
|||
scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.xquantity.compare"));
|
||||
|
||||
/* not constexpr until c++26 */
|
||||
xquantity ng = 1000 * unit_qty(su::nanogram);
|
||||
xquantity ug = unit_qty(su::microgram);
|
||||
xquantity ng = 1000 * unit_qty(u::nanogram);
|
||||
xquantity ug = unit_qty(u::microgram);
|
||||
|
||||
{
|
||||
auto cmp = (ng == ug);
|
||||
|
|
@ -617,8 +617,8 @@ namespace xo {
|
|||
scope log(XO_DEBUG2(c_debug_flag, "TEST_CASE.xquantity.compare2"));
|
||||
|
||||
/* not constexpr until c++26 */
|
||||
xquantity ng = unit_qty(su::nanogram);
|
||||
xquantity ug = unit_qty(su::microgram);
|
||||
xquantity ng = unit_qty(u::nanogram);
|
||||
xquantity ug = unit_qty(u::microgram);
|
||||
|
||||
{
|
||||
auto cmp = (ng == ug);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue