xo-unit: + repr argument to stdquantity

This commit is contained in:
Roland Conybeare 2024-05-03 21:37:22 -04:00
commit 83424e1ee3
3 changed files with 6 additions and 5 deletions

View file

@ -38,4 +38,5 @@ main () {
cerr << "a3: " << a3 << endl;
}
/** end ex2.cpp **/

View file

@ -8,14 +8,13 @@ int
main () {
namespace q = xo::qty::qty;
namespace u = xo::qty::nu;
using xo::qty::with_units;
using xo::qty::stdquantity;
using xo::qty::quantity;
using xo::flatstring;
using namespace std;
constexpr stdquantity<u::second> t = q::minutes(2);
constexpr stdquantity<u::meter> d = q::kilometers(2.5);
constexpr stdquantity<double, u::second> t = q::minutes(2);
constexpr stdquantity<double, u::meter> d = q::kilometers(2.5);
constexpr auto t2 = t*t;
constexpr auto a = d / (t*t);

View file

@ -157,8 +157,9 @@ namespace xo {
Repr scale_ = Repr{};
};
template <natural_unit<::std::int64_t> NaturalUnit = natural_unit<::std::int64_t>()>
using stdquantity = xo::qty::quantity<double, ::std::int64_t, NaturalUnit>;
template <typename Repr = double,
natural_unit<std::int64_t> NaturalUnit = natural_unit<std::int64_t>()>
using stdquantity = quantity<Repr, std::int64_t, NaturalUnit>;
template <typename Quantity, typename Int, typename Int2x>
constexpr auto