mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
hectometre and hectare added
This commit is contained in:
@@ -35,6 +35,8 @@ struct square_millimetre : deduced_unit<square_millimetre, dim_area, millimetre>
|
|||||||
struct square_centimetre : deduced_unit<square_centimetre, dim_area, centimetre> {};
|
struct square_centimetre : deduced_unit<square_centimetre, dim_area, centimetre> {};
|
||||||
struct square_kilometre : deduced_unit<square_kilometre, dim_area, kilometre> {};
|
struct square_kilometre : deduced_unit<square_kilometre, dim_area, kilometre> {};
|
||||||
|
|
||||||
|
struct hectare : deduced_unit<hectare, dim_area, hectometre> {};
|
||||||
|
|
||||||
template<Unit U, Scalar Rep = double>
|
template<Unit U, Scalar Rep = double>
|
||||||
using area = quantity<dim_area, U, Rep>;
|
using area = quantity<dim_area, U, Rep>;
|
||||||
|
|
||||||
@@ -56,6 +58,10 @@ constexpr auto operator"" sq_cm(long double l) { return area<square_centimetre,
|
|||||||
constexpr auto operator"" sq_km(unsigned long long l) { return area<square_kilometre, std::int64_t>(l); }
|
constexpr auto operator"" sq_km(unsigned long long l) { return area<square_kilometre, std::int64_t>(l); }
|
||||||
constexpr auto operator"" sq_km(long double l) { return area<square_kilometre, long double>(l); }
|
constexpr auto operator"" sq_km(long double l) { return area<square_kilometre, long double>(l); }
|
||||||
|
|
||||||
|
// ha
|
||||||
|
constexpr auto operator"" ha(unsigned long long l) { return area<hectare, std::int64_t>(l); }
|
||||||
|
constexpr auto operator"" ha(long double l) { return area<hectare, long double>(l); }
|
||||||
|
|
||||||
} // namespace literals
|
} // namespace literals
|
||||||
|
|
||||||
} // namespace units::si
|
} // namespace units::si
|
||||||
|
@@ -32,6 +32,7 @@ struct metre : named_unit<metre, "m", prefix> {};
|
|||||||
struct millimetre : prefixed_unit<millimetre, milli, metre> {};
|
struct millimetre : prefixed_unit<millimetre, milli, metre> {};
|
||||||
struct centimetre : prefixed_unit<centimetre, centi, metre> {};
|
struct centimetre : prefixed_unit<centimetre, centi, metre> {};
|
||||||
struct decimetre : prefixed_unit<decimetre, deci, metre> {};
|
struct decimetre : prefixed_unit<decimetre, deci, metre> {};
|
||||||
|
struct hectometre : prefixed_unit<hectometre, hecto, metre> {};
|
||||||
struct kilometre : prefixed_unit<kilometre, kilo, 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 astronomical_unit : named_scaled_unit<astronomical_unit, "au", no_prefix, ratio<149'597'870'700>, metre> {};
|
||||||
@@ -59,6 +60,10 @@ constexpr auto operator"" cm(long double l) { return length<centimetre, long dou
|
|||||||
constexpr auto operator"" dm(unsigned long long l) { return length<decimetre, std::int64_t>(l); }
|
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); }
|
constexpr auto operator"" dm(long double l) { return length<decimetre, long double>(l); }
|
||||||
|
|
||||||
|
// hm
|
||||||
|
constexpr auto operator"" hm(unsigned long long l) { return length<hectometre, std::int64_t>(l); }
|
||||||
|
constexpr auto operator"" hm(long double l) { return length<hectometre, long double>(l); }
|
||||||
|
|
||||||
// km
|
// km
|
||||||
constexpr auto operator"" km(unsigned long long l) { return length<kilometre, std::int64_t>(l); }
|
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); }
|
constexpr auto operator"" km(long double l) { return length<kilometre, long double>(l); }
|
||||||
|
@@ -55,6 +55,7 @@ static_assert(1km == 1000m);
|
|||||||
static_assert(1m == 100cm);
|
static_assert(1m == 100cm);
|
||||||
static_assert(1m == 10dm);
|
static_assert(1m == 10dm);
|
||||||
static_assert(1m == 1000mm);
|
static_assert(1m == 1000mm);
|
||||||
|
static_assert(1hm == 100m);
|
||||||
static_assert(1au == 149'597'870'700m);
|
static_assert(1au == 149'597'870'700m);
|
||||||
static_assert(1km + 1m == 1001m);
|
static_assert(1km + 1m == 1001m);
|
||||||
static_assert(10km / 5km == 2);
|
static_assert(10km / 5km == 2);
|
||||||
@@ -225,6 +226,7 @@ static_assert(10m * 10m == 100sq_m);
|
|||||||
static_assert(100sq_m / 10m == 10m);
|
static_assert(100sq_m / 10m == 10m);
|
||||||
static_assert(10km * 10km == 100sq_km);
|
static_assert(10km * 10km == 100sq_km);
|
||||||
static_assert(1sq_m == 10'000sq_cm);
|
static_assert(1sq_m == 10'000sq_cm);
|
||||||
|
static_assert(1ha == 10'000sq_m);
|
||||||
|
|
||||||
static_assert(detail::unit_text<dim_area, square_metre>() == "m²");
|
static_assert(detail::unit_text<dim_area, square_metre>() == "m²");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user