astronomical unit added

This commit is contained in:
Mateusz Pusz
2019-12-26 10:11:12 +01:00
parent 15e148381d
commit 70fbf300b4
2 changed files with 7 additions and 0 deletions

View File

@@ -34,6 +34,8 @@ struct centimetre : prefixed_unit<centimetre, centi, metre> {};
struct decimetre : prefixed_unit<decimetre, deci, metre> {};
struct kilometre : prefixed_unit<kilometre, kilo, metre> {};
struct astronomical_unit : named_scaled_unit<astronomical_unit, "au", no_prefix, ratio<149'597'870'700>, metre> {};
struct dim_length : physical::dim_length<metre> {};
template<Unit U, Scalar Rep = double>
@@ -61,6 +63,10 @@ constexpr auto operator"" dm(long double l) { return length<decimetre, long doub
constexpr auto operator"" km(unsigned long long l) { return length<kilometre, std::int64_t>(l); }
constexpr auto operator"" km(long double l) { return length<kilometre, long double>(l); }
// au
constexpr auto operator"" au(unsigned long long l) { return length<astronomical_unit, std::int64_t>(l); }
constexpr auto operator"" au(long double l) { return length<astronomical_unit, long double>(l); }
} // namespace literals
} // namespace units::si

View File

@@ -55,6 +55,7 @@ static_assert(1km == 1000m);
static_assert(1m == 100cm);
static_assert(1m == 10dm);
static_assert(1m == 1000mm);
static_assert(1au == 149'597'870'700m);
static_assert(1km + 1m == 1001m);
static_assert(10km / 5km == 2);
static_assert(100mm / 5cm == 2);