mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
decimetre and litre added
This commit is contained in:
@@ -31,6 +31,7 @@ namespace units::si {
|
||||
struct metre : named_unit<metre, "m", prefix> {};
|
||||
struct millimetre : prefixed_unit<millimetre, milli, metre> {};
|
||||
struct centimetre : prefixed_unit<centimetre, centi, metre> {};
|
||||
struct decimetre : prefixed_unit<decimetre, deci, metre> {};
|
||||
struct kilometre : prefixed_unit<kilometre, kilo, metre> {};
|
||||
|
||||
struct dim_length : physical::dim_length<metre> {};
|
||||
@@ -52,6 +53,10 @@ constexpr auto operator"" mm(long double l) { return length<millimetre, long dou
|
||||
constexpr auto operator"" cm(unsigned long long l) { return length<centimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" cm(long double l) { return length<centimetre, long double>(l); }
|
||||
|
||||
// dm
|
||||
constexpr auto operator"" dm(unsigned long long l) { return length<decimetre, std::int64_t>(l); }
|
||||
constexpr auto operator"" dm(long double l) { return length<decimetre, long double>(l); }
|
||||
|
||||
// km
|
||||
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); }
|
||||
|
@@ -35,6 +35,9 @@ struct cubic_millimetre : deduced_unit<cubic_millimetre, dim_volume, millimetre>
|
||||
struct cubic_centimetre : deduced_unit<cubic_centimetre, dim_volume, centimetre> {};
|
||||
struct cubic_kilometre : deduced_unit<cubic_kilometre, dim_volume, kilometre> {};
|
||||
|
||||
struct litre : deduced_unit<litre, dim_volume, decimetre> {};
|
||||
|
||||
|
||||
template<Unit U, Scalar Rep = double>
|
||||
using volume = quantity<dim_volume, U, Rep>;
|
||||
|
||||
@@ -56,6 +59,10 @@ constexpr auto operator""cub_m(long double l) { return volume<cubic_metre, long
|
||||
constexpr auto operator""cub_km(unsigned long long l) { return volume<cubic_kilometre, std::int64_t>(l); }
|
||||
constexpr auto operator""cub_km(long double l) { return volume<cubic_kilometre, long double>(l); }
|
||||
|
||||
// l
|
||||
constexpr auto operator""_l(unsigned long long l) { return volume<litre, std::int64_t>(l); }
|
||||
constexpr auto operator""_l(long double l) { return volume<litre, long double>(l); }
|
||||
|
||||
} // namespace literals
|
||||
|
||||
} // namespace units::si
|
||||
|
@@ -53,6 +53,7 @@ using namespace units::si;
|
||||
|
||||
static_assert(1km == 1000m);
|
||||
static_assert(1m == 100cm);
|
||||
static_assert(1m == 10dm);
|
||||
static_assert(1m == 1000mm);
|
||||
static_assert(1km + 1m == 1001m);
|
||||
static_assert(10km / 5km == 2);
|
||||
@@ -61,6 +62,7 @@ static_assert(10km / 2 == 5km);
|
||||
|
||||
static_assert(millimetre::symbol == "mm");
|
||||
static_assert(centimetre::symbol == "cm");
|
||||
static_assert(decimetre::symbol == "dm");
|
||||
static_assert(kilometre::symbol == "km");
|
||||
|
||||
// mass
|
||||
@@ -231,6 +233,8 @@ static_assert(1m * 1m * 1m == 1cub_m);
|
||||
static_assert(10sq_m * 10m == 100cub_m);
|
||||
static_assert(10km * 10km * 10km == 1000cub_km);
|
||||
static_assert(1cub_m == 1'000'000cub_cm);
|
||||
static_assert(1dm * 1dm * 1dm == 1_l);
|
||||
static_assert(1000_l == 1cub_m);
|
||||
|
||||
static_assert(detail::unit_text<dim_volume, cubic_metre>() == "m³");
|
||||
|
||||
|
Reference in New Issue
Block a user