Strong units support added
This commit is contained in:
1 parent
7205dc2cb9
commit
e866985668
7 files changed
+78
-42
No files matched your search
@@ -27,16 +27,27 @@
|
||||
|
||||
namespace units {
|
||||
|
||||
|
||||
using millihertz = unit<dimension_frequency, std::milli>;
|
||||
using hertz = unit<dimension_frequency, std::ratio<1>>;
|
||||
using kilohertz = unit<dimension_frequency, std::kilo>;
|
||||
using megahertz = unit<dimension_frequency, std::mega>;
|
||||
using gigahertz = unit<dimension_frequency, std::giga>;
|
||||
using terahertz = unit<dimension_frequency, std::tera>;
|
||||
struct dimension_frequency : make_dimension_t<exp<base_dim_time, -1>> {};
|
||||
template<> struct dimension_traits<typename dimension_frequency::type> : std::type_identity<dimension_frequency> {};
|
||||
|
||||
struct millihertz : unit<dimension_frequency, std::milli> {};
|
||||
template<> struct unit_traits<typename millihertz::type> : std::type_identity<millihertz> {};
|
||||
|
||||
struct hertz : unit<dimension_frequency, std::ratio<1>> {};
|
||||
template<> struct unit_traits<typename hertz::type> : std::type_identity<hertz> {};
|
||||
|
||||
struct kilohertz : unit<dimension_frequency, std::kilo> {};
|
||||
template<> struct unit_traits<typename kilohertz::type> : std::type_identity<kilohertz> {};
|
||||
|
||||
struct megahertz : unit<dimension_frequency, std::mega> {};
|
||||
template<> struct unit_traits<typename megahertz::type> : std::type_identity<megahertz> {};
|
||||
|
||||
struct gigahertz : unit<dimension_frequency, std::giga> {};
|
||||
template<> struct unit_traits<typename gigahertz::type> : std::type_identity<gigahertz> {};
|
||||
|
||||
struct terahertz : unit<dimension_frequency, std::tera> {};
|
||||
template<> struct unit_traits<typename terahertz::type> : std::type_identity<terahertz> {};
|
||||
|
||||
template<Unit U = hertz, Number Rep = std::intmax_t>
|
||||
using frequency = quantity<dimension_frequency, U, Rep>;
|
||||
|
||||
|
||||
@@ -30,10 +30,17 @@ namespace units {
|
||||
struct dimension_length : make_dimension_t<exp<base_dim_length, 1>> {};
|
||||
template<> struct dimension_traits<typename dimension_length::type> : std::type_identity<dimension_length> {};
|
||||
|
||||
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>;
|
||||
struct millimeter : unit<dimension_length, std::milli> {};
|
||||
template<> struct unit_traits<typename millimeter::type> : std::type_identity<millimeter> {};
|
||||
|
||||
struct centimeter : unit<dimension_length, std::ratio<1, 100>> {};
|
||||
template<> struct unit_traits<typename centimeter::type> : std::type_identity<centimeter> {};
|
||||
|
||||
struct meter : unit<dimension_length, std::ratio<1>> {};
|
||||
template<> struct unit_traits<typename meter::type> : std::type_identity<meter> {};
|
||||
|
||||
struct kilometer : unit<dimension_length, std::kilo> {};
|
||||
template<> struct unit_traits<typename kilometer::type> : std::type_identity<kilometer> {};
|
||||
|
||||
template<Unit U = meter, Number Rep = std::intmax_t>
|
||||
using length = quantity<dimension_length, U, Rep>;
|
||||
|
||||
@@ -27,15 +27,26 @@
|
||||
|
||||
namespace units {
|
||||
|
||||
using nanosecond = unit<dimension_time, std::nano>;
|
||||
using microsecond = unit<dimension_time, std::micro>;
|
||||
using millisecond = unit<dimension_time, std::milli>;
|
||||
using second = unit<dimension_time, std::ratio<1>>;
|
||||
using minute = unit<dimension_time, std::ratio<60>>;
|
||||
using hour = unit<dimension_time, std::ratio<3600>>;
|
||||
struct dimension_time : make_dimension_t<exp<base_dim_time, 1>> {};
|
||||
template<> struct dimension_traits<typename dimension_time::type> : std::type_identity<dimension_time> {};
|
||||
|
||||
struct nanosecond : unit<dimension_time, std::nano> {};
|
||||
template<> struct unit_traits<typename nanosecond::type> : std::type_identity<nanosecond> {};
|
||||
|
||||
struct microsecond : unit<dimension_time, std::micro> {};
|
||||
template<> struct unit_traits<typename microsecond::type> : std::type_identity<microsecond> {};
|
||||
|
||||
struct millisecond : unit<dimension_time, std::milli> {};
|
||||
template<> struct unit_traits<typename millisecond::type> : std::type_identity<millisecond> {};
|
||||
|
||||
struct second : unit<dimension_time, std::ratio<1>> {};
|
||||
template<> struct unit_traits<typename second::type> : std::type_identity<second> {};
|
||||
|
||||
struct minute : unit<dimension_time, std::ratio<60>> {};
|
||||
template<> struct unit_traits<typename minute::type> : std::type_identity<minute> {};
|
||||
|
||||
struct hour : unit<dimension_time, std::ratio<3600>> {};
|
||||
template<> struct unit_traits<typename hour::type> : std::type_identity<hour> {};
|
||||
|
||||
template<Unit U = second, Number Rep = std::intmax_t>
|
||||
using time = quantity<dimension_time, U, Rep>;
|
||||
|
||||
@@ -31,9 +31,14 @@ namespace units {
|
||||
struct dimension_velocity : make_dimension_t<exp<base_dim_length, 1>, exp<base_dim_time, -1>> {};
|
||||
template<> struct dimension_traits<typename dimension_velocity::type> : std::type_identity<dimension_velocity> {};
|
||||
|
||||
using meter_per_second = unit<dimension_velocity, std::ratio<1>>;
|
||||
using kilometer_per_hour = unit<dimension_velocity, std::ratio<1000, 3600>>;
|
||||
using mile_per_hour = unit<dimension_velocity, std::ratio<44'704, 100'000>>;
|
||||
struct meter_per_second : unit<dimension_velocity, std::ratio<1>> {};
|
||||
template<> struct unit_traits<typename meter_per_second::type> : std::type_identity<meter_per_second> {};
|
||||
|
||||
struct kilometer_per_hour : unit<dimension_velocity, std::ratio<1000, 3600>> {};
|
||||
template<> struct unit_traits<typename kilometer_per_hour::type> : std::type_identity<kilometer_per_hour> {};
|
||||
|
||||
struct mile_per_hour : unit<dimension_velocity, std::ratio<44'704, 100'000>> {};
|
||||
template<> struct unit_traits<typename mile_per_hour::type> : std::type_identity<mile_per_hour> {};
|
||||
|
||||
template<Unit U = meter_per_second, Number Rep = std::intmax_t>
|
||||
using velocity = quantity<dimension_velocity, U, Rep>;
|
||||
|
||||
Reference in new issue
Block a user