Centimeters support added

This commit is contained in:
Mateusz Pusz
2018-10-16 15:39:39 +02:00
parent 772d0e0889
commit 4796d777b9
2 changed files with 7 additions and 0 deletions

View File

@@ -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); }

View File

@@ -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>>);