forked from mpusz/mp-units
Prefixes support added
This commit is contained in:
@@ -36,22 +36,22 @@ namespace units {
|
||||
template<Unit U = struct hertz, Number Rep = double>
|
||||
using frequency = quantity<dimension_frequency, U, Rep>;
|
||||
|
||||
struct millihertz : unit<dimension_frequency, std::milli> {};
|
||||
template<> struct upcasting_traits<upcast_from<millihertz>> : upcast_to<millihertz> {};
|
||||
|
||||
struct hertz : derived_unit<dimension_frequency, second> {};
|
||||
template<> struct upcasting_traits<upcast_from<hertz>> : upcast_to<hertz> {};
|
||||
|
||||
struct kilohertz : unit<dimension_frequency, std::kilo> {};
|
||||
struct millihertz : milli<hertz> {};
|
||||
template<> struct upcasting_traits<upcast_from<millihertz>> : upcast_to<millihertz> {};
|
||||
|
||||
struct kilohertz : kilo<hertz> {};
|
||||
template<> struct upcasting_traits<upcast_from<kilohertz>> : upcast_to<kilohertz> {};
|
||||
|
||||
struct megahertz : unit<dimension_frequency, std::mega> {};
|
||||
struct megahertz : mega<hertz> {};
|
||||
template<> struct upcasting_traits<upcast_from<megahertz>> : upcast_to<megahertz> {};
|
||||
|
||||
struct gigahertz : unit<dimension_frequency, std::giga> {};
|
||||
struct gigahertz : giga<hertz> {};
|
||||
template<> struct upcasting_traits<upcast_from<gigahertz>> : upcast_to<gigahertz> {};
|
||||
|
||||
struct terahertz : unit<dimension_frequency, std::tera> {};
|
||||
struct terahertz : tera<hertz> {};
|
||||
template<> struct upcasting_traits<upcast_from<terahertz>> : upcast_to<terahertz> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
@@ -37,16 +37,16 @@ namespace units {
|
||||
using length = quantity<dimension_length, U, Rep>;
|
||||
|
||||
// SI units
|
||||
struct millimeter : unit<dimension_length, std::milli> {};
|
||||
template<> struct upcasting_traits<upcast_from<millimeter>> : upcast_to<millimeter> {};
|
||||
|
||||
struct centimeter : unit<dimension_length, std::ratio<1, 100>> {};
|
||||
template<> struct upcasting_traits<upcast_from<centimeter>> : upcast_to<centimeter> {};
|
||||
|
||||
struct meter : unit<dimension_length, std::ratio<1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<meter>> : upcast_to<meter> {};
|
||||
|
||||
struct kilometer : unit<dimension_length, std::kilo> {};
|
||||
struct millimeter : milli<meter> {};
|
||||
template<> struct upcasting_traits<upcast_from<millimeter>> : upcast_to<millimeter> {};
|
||||
|
||||
struct centimeter : centi<meter> {};
|
||||
template<> struct upcasting_traits<upcast_from<centimeter>> : upcast_to<centimeter> {};
|
||||
|
||||
struct kilometer : kilo<meter> {};
|
||||
template<> struct upcasting_traits<upcast_from<kilometer>> : upcast_to<kilometer> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
@@ -39,11 +39,15 @@ namespace units {
|
||||
struct gram : unit<dimension_mass, std::milli> {};
|
||||
template<> struct upcasting_traits<upcast_from<gram>> : upcast_to<gram> {};
|
||||
|
||||
struct kilogram : unit<dimension_mass, std::ratio<1>> {};
|
||||
struct kilogram : kilo<gram> {};
|
||||
template<> struct upcasting_traits<upcast_from<kilogram>> : upcast_to<kilogram> {};
|
||||
|
||||
inline namespace literals {
|
||||
|
||||
// g
|
||||
constexpr auto operator""_g(unsigned long long l) { return mass<gram, std::int64_t>(l); }
|
||||
constexpr auto operator""_g(long double l) { return mass<gram, long double>(l); }
|
||||
|
||||
// kg
|
||||
constexpr auto operator""_kg(unsigned long long l) { return mass<kilogram, std::int64_t>(l); }
|
||||
constexpr auto operator""_kg(long double l) { return mass<kilogram, long double>(l); }
|
||||
|
@@ -36,18 +36,18 @@ namespace units {
|
||||
template<Unit U = struct second, Number Rep = double>
|
||||
using time = quantity<dimension_time, U, Rep>;
|
||||
|
||||
struct nanosecond : unit<dimension_time, std::nano> {};
|
||||
template<> struct upcasting_traits<upcast_from<nanosecond>> : upcast_to<nanosecond> {};
|
||||
|
||||
struct microsecond : unit<dimension_time, std::micro> {};
|
||||
template<> struct upcasting_traits<upcast_from<microsecond>> : upcast_to<microsecond> {};
|
||||
|
||||
struct millisecond : unit<dimension_time, std::milli> {};
|
||||
template<> struct upcasting_traits<upcast_from<millisecond>> : upcast_to<millisecond> {};
|
||||
|
||||
struct second : unit<dimension_time, std::ratio<1>> {};
|
||||
template<> struct upcasting_traits<upcast_from<second>> : upcast_to<second> {};
|
||||
|
||||
struct nanosecond : nano<second> {};
|
||||
template<> struct upcasting_traits<upcast_from<nanosecond>> : upcast_to<nanosecond> {};
|
||||
|
||||
struct microsecond : micro<second> {};
|
||||
template<> struct upcasting_traits<upcast_from<microsecond>> : upcast_to<microsecond> {};
|
||||
|
||||
struct millisecond : milli<second> {};
|
||||
template<> struct upcasting_traits<upcast_from<millisecond>> : upcast_to<millisecond> {};
|
||||
|
||||
struct minute : unit<dimension_time, std::ratio<60>> {};
|
||||
template<> struct upcasting_traits<upcast_from<minute>> : upcast_to<minute> {};
|
||||
|
||||
|
@@ -112,4 +112,21 @@ namespace units {
|
||||
template<Dimension D, Unit... Us>
|
||||
using derived_unit = unit<D, typename detail::derived_ratio<typename D::base_type, Us...>::ratio>;
|
||||
|
||||
// prefixes
|
||||
template<Unit U> using atto = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::atto>>;
|
||||
template<Unit U> using femto = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::femto>>;
|
||||
template<Unit U> using pico = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::pico>>;
|
||||
template<Unit U> using nano = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::nano>>;
|
||||
template<Unit U> using micro = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::micro>>;
|
||||
template<Unit U> using milli = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::milli>>;
|
||||
template<Unit U> using centi = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::centi>>;
|
||||
template<Unit U> using deca = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::deca>>;
|
||||
template<Unit U> using hecto = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::hecto>>;
|
||||
template<Unit U> using kilo = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::kilo>>;
|
||||
template<Unit U> using mega = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::mega>>;
|
||||
template<Unit U> using giga = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::giga>>;
|
||||
template<Unit U> using tera = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::tera>>;
|
||||
template<Unit U> using peta = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::peta>>;
|
||||
template<Unit U> using exa = unit<typename U::dimension, std::ratio_multiply<typename U::ratio, std::exa>>;
|
||||
|
||||
} // namespace units
|
||||
|
Reference in New Issue
Block a user