mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-01 03:14:29 +02:00
Centimeters support added
This commit is contained in:
@@ -30,6 +30,7 @@ namespace units {
|
||||
using dimension_length = make_dimension_t<exp<base_dim_length, 1>>;
|
||||
|
||||
using millimeter = unit<dimension_length, std::milli>;
|
||||
using centimeter = unit<dimension_length, std::ratio<1, 100>>;
|
||||
using meter = unit<dimension_length, std::ratio<1>>;
|
||||
using kilometer = unit<dimension_length, std::kilo>;
|
||||
|
||||
@@ -55,6 +56,10 @@ namespace units {
|
||||
constexpr auto operator""_mm(unsigned long long l) { return length<millimeter, std::int64_t>(l); }
|
||||
constexpr auto operator""_mm(long double l) { return length<millimeter, long double>(l); }
|
||||
|
||||
// cm
|
||||
constexpr auto operator""_cm(unsigned long long l) { return length<centimeter, std::int64_t>(l); }
|
||||
constexpr auto operator""_cm(long double l) { return length<centimeter, long double>(l); }
|
||||
|
||||
// m
|
||||
constexpr auto operator""_m(unsigned long long l) { return length<meter, std::int64_t>(l); }
|
||||
constexpr auto operator""_m(long double l) { return length<meter, long double>(l); }
|
||||
|
@@ -48,6 +48,8 @@ namespace {
|
||||
static_assert(10_km / 5_km == 2);
|
||||
static_assert(10_km / 2 == 5_km);
|
||||
|
||||
static_assert(1_m == 100_cm)//static_assert(5_in + 8_cm == 207_mm);
|
||||
|
||||
// velocity
|
||||
|
||||
static_assert(std::is_same_v<decltype(1_km / 1_s), velocity<unit<dimension_velocity, std::ratio<1000, 1>>, long long int>>);
|
||||
|
Reference in New Issue
Block a user