xo-unit: stop hardwiring representation for a few qty builders

This commit is contained in:
Roland Conybeare 2024-05-03 21:35:53 -04:00
commit f3e75cc634
2 changed files with 11 additions and 6 deletions

View file

@ -23,8 +23,8 @@ main () {
<< ", d.t^-2: " << a
<< endl;
static_assert(std::same_as<decltype(t)::repr_type, double>);
static_assert(sizeof(t) == sizeof(double));
static_assert(std::same_as<decltype(t)::repr_type, int>);
static_assert(sizeof(t) == sizeof(int));
static_assert(t.scale() == 2);
static_assert(t.abbrev() == flatstring("min"));
@ -33,8 +33,8 @@ main () {
static_assert(d.scale() == 2.5);
static_assert(d.abbrev() == flatstring("km"));
static_assert(std::same_as<decltype(t2)::repr_type, double>);
static_assert(sizeof(t2) == sizeof(double));
static_assert(std::same_as<decltype(t2)::repr_type, int>);
static_assert(sizeof(t2) == sizeof(int));
static_assert(t2.scale() == 4);
static_assert(t2.abbrev() == flatstring("min^2"));

View file

@ -313,8 +313,13 @@ namespace xo {
inline constexpr auto nanoseconds(double x) { return quantity<double, std::int64_t, nu::nanosecond>(x); }
inline constexpr auto microseconds(double x) { return quantity<double, std::int64_t, nu::microsecond>(x); }
inline constexpr auto milliseconds(double x) { return quantity<double, std::int64_t, nu::millisecond>(x); }
inline constexpr auto seconds(double x) { return quantity<double, std::int64_t, nu::second>(x); }
inline constexpr auto minutes(double x) { return quantity<double, std::int64_t, nu::minute>(x); }
template <typename Repr>
inline constexpr auto seconds(Repr x) { return quantity<Repr, std::int64_t, nu::second>(x); }
template <typename Repr>
inline constexpr auto minutes(Repr x) { return quantity<Repr, std::int64_t, nu::minute>(x); }
inline constexpr auto hours(double x) { return quantity<double, std::int64_t, nu::hour>(x); }
inline constexpr auto days(double x) { return quantity<double, std::int64_t, nu::day>(x); }
inline constexpr auto weeks(double x) { return quantity<double, std::int64_t, nu::week>(x); }