|
quanta 0.1.0
Type-safe units for temperature, frequency, electrical and spatial quantities, modeled after std::chrono
|
Type-safe units modeled after std::chrono. More...
Namespaces | |
| namespace | electro |
| Electrical unit types and utilities. | |
| namespace | electro_literals |
| namespace | frequency |
| Frequency types and utilities. | |
| namespace | frequency_literals |
| namespace | literals |
| namespace | spatial |
| Spatial unit types and utilities. | |
| namespace | spatial_literals |
| namespace | thermo |
| Temperature types and utilities. | |
| namespace | thermo_literals |
Classes | |
| struct | base_unit_t |
| Tag type selecting the base-unit form, see base_unit. More... | |
| struct | scaled_t |
| Tag type selecting the scaled form, see scaled. More... | |
| struct | treat_as_inexact |
| Trait to indicate floating-point-like behavior. More... | |
Functions | |
| template<char... Digits> | |
| constexpr quanta::electro::decibels | operator""_dB () |
| Literal for decibels (e.g., 20_dB). | |
| template<char... Digits> | |
| constexpr quanta::electro::centidecibels | operator""_cdB () |
| Literal for centidecibels, i.e. | |
| template<char... Digits> | |
| constexpr quanta::electro::dbm | operator""_dBm () |
| Literal for dBm (e.g., 20_dBm, or -73_dBm). | |
| template<char... Digits> | |
| constexpr quanta::electro::centi_dbm | operator""_cdBm () |
| Literal for dBm in 0.01 dB steps (e.g., 1301_cdBm is 13.01 dBm). | |
| template<char... Digits> | |
| constexpr quanta::electro::dbw | operator""_dBW () |
| Literal for dBW (e.g., 10_dBW). | |
| template<char... Digits> | |
| constexpr quanta::electro::dbv | operator""_dBV () |
| Literal for dBV (e.g., 6_dBV). | |
| template<char... Digits> | |
| constexpr quanta::electro::dbmv | operator""_dBmV () |
| Literal for dBmV (e.g., 40_dBmV). | |
| template<char... Digits> | |
| constexpr quanta::electro::dbuv | operator""_dBuV () |
| Literal for dBµV (e.g., 120_dBuV). | |
| template<char... Digits> | |
| constexpr quanta::electro::dbuv | operator""_dBµV () |
| Literal for dBµV (e.g., 120_dBµV). | |
| template<char... Digits> | |
| constexpr quanta::electro::microvolts | operator""_uV () |
| Literal for microvolts (e.g., 500_uV). | |
| template<char... Digits> | |
| constexpr quanta::electro::millivolts | operator""_mV () |
| Literal for millivolts (e.g., 3300_mV). | |
| template<char... Digits> | |
| constexpr quanta::electro::volts | operator""_V () |
| Literal for volts (e.g., 5_V). | |
| template<char... Digits> | |
| constexpr quanta::electro::kilovolts | operator""_kV () |
| Literal for kilovolts (e.g., 11_kV). | |
| template<char... Digits> | |
| constexpr quanta::electro::microamperes | operator""_uA () |
| Literal for microamperes (e.g., 250_uA). | |
| template<char... Digits> | |
| constexpr quanta::electro::milliamperes | operator""_mA () |
| Literal for milliamperes (e.g., 150_mA). | |
| template<char... Digits> | |
| constexpr quanta::electro::amperes | operator""_A () |
| Literal for amperes (e.g., 2_A). | |
| template<char... Digits> | |
| constexpr quanta::electro::milliohms | operator""_mOhm () |
| Literal for milliohms (e.g., 50_mOhm). | |
| template<char... Digits> | |
| constexpr quanta::electro::ohms | operator""_Ohm () |
| Literal for ohms (e.g., 220_Ohm). | |
| template<char... Digits> | |
| constexpr quanta::electro::kiloohms | operator""_kOhm () |
| Literal for kiloohms (e.g., 10_kOhm). | |
| template<char... Digits> | |
| constexpr quanta::electro::megaohms | operator""_MOhm () |
| Literal for megaohms (e.g., 1_MOhm). | |
| template<char... Digits> | |
| constexpr quanta::electro::milliohms | operator""_mΩ () |
| Literal for milliohms (e.g., 50_mΩ). | |
| template<char... Digits> | |
| constexpr quanta::electro::ohms | operator""_Ω () |
| Literal for ohms (e.g., 220_Ω). | |
| template<char... Digits> | |
| constexpr quanta::electro::kiloohms | operator""_kΩ () |
| Literal for kiloohms (e.g., 10_kΩ). | |
| template<char... Digits> | |
| constexpr quanta::electro::megaohms | operator""_MΩ () |
| Literal for megaohms (e.g., 1_MΩ). | |
| template<char... Digits> | |
| constexpr quanta::electro::microwatts | operator""_uW () |
| Literal for microwatts (e.g., 500_uW). | |
| template<char... Digits> | |
| constexpr quanta::electro::milliwatts | operator""_mW () |
| Literal for milliwatts (e.g., 250_mW). | |
| template<char... Digits> | |
| constexpr quanta::electro::watts | operator""_W () |
| Literal for watts (e.g., 60_W). | |
| template<char... Digits> | |
| constexpr quanta::electro::kilowatts | operator""_kW () |
| Literal for kilowatts (e.g., 2_kW). | |
| template<char... Digits> | |
| constexpr quanta::electro::megawatts | operator""_MW () |
| Literal for megawatts (e.g., 5_MW). | |
| template<char... Digits> | |
| constexpr quanta::electro::coulombs | operator""_C () |
| Literal for coulombs (e.g., 10_C). | |
| template<char... Digits> | |
| constexpr quanta::electro::milliampere_hours | operator""_mAh () |
| Literal for milliampere-hours (e.g., 2000_mAh). | |
| template<char... Digits> | |
| constexpr quanta::electro::ampere_hours | operator""_Ah () |
| Literal for ampere-hours (e.g., 2_Ah). | |
| template<char... Digits> | |
| constexpr quanta::electro::millijoules | operator""_mJ () |
| Literal for millijoules (e.g., 500_mJ). | |
| template<char... Digits> | |
| constexpr quanta::electro::joules | operator""_J () |
| Literal for joules (e.g., 100_J). | |
| template<char... Digits> | |
| constexpr quanta::electro::kilojoules | operator""_kJ () |
| Literal for kilojoules (e.g., 4_kJ). | |
| template<char... Digits> | |
| constexpr quanta::electro::watt_hours | operator""_Wh () |
| Literal for watt-hours (e.g., 100_Wh). | |
| template<char... Digits> | |
| constexpr quanta::electro::kilowatt_hours | operator""_kWh () |
| Literal for kilowatt-hours (e.g., 10_kWh). | |
| template<char... Digits> | |
| constexpr quanta::electro::picofarads | operator""_pF () |
| Literal for picofarads (e.g., 22_pF). | |
| template<char... Digits> | |
| constexpr quanta::electro::nanofarads | operator""_nF () |
| Literal for nanofarads (e.g., 100_nF). | |
| template<char... Digits> | |
| constexpr quanta::electro::microfarads | operator""_uF () |
| Literal for microfarads (e.g., 10_uF). | |
| template<char... Digits> | |
| constexpr quanta::electro::farads | operator""_F () |
| Literal for farads (e.g., 1_F). | |
| template<char... Digits> | |
| constexpr quanta::electro::nanohenries | operator""_nH () |
| Literal for nanohenries (e.g., 100_nH). | |
| template<char... Digits> | |
| constexpr quanta::electro::microhenries | operator""_uH () |
| Literal for microhenries (e.g., 47_uH). | |
| template<char... Digits> | |
| constexpr quanta::electro::millihenries | operator""_mH () |
| Literal for millihenries (e.g., 10_mH). | |
| template<char... Digits> | |
| constexpr quanta::electro::henries | operator""_H () |
| Literal for henries (e.g., 1_H). | |
| template<char... Digits> | |
| constexpr quanta::frequency::millihertz | operator""_mHz () |
| Literal for millihertz (e.g., 1000_mHz). | |
| template<char... Digits> | |
| constexpr quanta::frequency::hertz | operator""_Hz () |
| Literal for hertz (e.g., 1000_Hz). | |
| template<char... Digits> | |
| constexpr quanta::frequency::kilohertz | operator""_kHz () |
| Literal for kilohertz (e.g., 80_kHz). | |
| template<char... Digits> | |
| constexpr quanta::frequency::megahertz | operator""_MHz () |
| Literal for megahertz (e.g., 80_MHz). | |
| template<char... Digits> | |
| constexpr quanta::frequency::gigahertz | operator""_GHz () |
| Literal for gigahertz (e.g., 2_GHz). | |
| template<char... Digits> | |
| constexpr quanta::frequency::terahertz | operator""_THz () |
| Literal for terahertz (e.g., 1_THz). | |
| template<char... Digits> | |
| constexpr quanta::spatial::nanometers | operator""_nm () |
| Literal for nanometers (e.g., 850_nm). | |
| template<char... Digits> | |
| constexpr quanta::spatial::micrometers | operator""_um () |
| Literal for micrometers (e.g., 50_um). | |
| template<char... Digits> | |
| constexpr quanta::spatial::micrometers | operator""_µm () |
| Literal for micrometers (e.g., 50_µm). | |
| template<char... Digits> | |
| constexpr quanta::spatial::millimeters | operator""_mm () |
| Literal for millimeters (e.g., 250_mm). | |
| template<char... Digits> | |
| constexpr quanta::spatial::centimeters | operator""_cm () |
| Literal for centimeters (e.g., 30_cm). | |
| template<char... Digits> | |
| constexpr quanta::spatial::meters | operator""_m () |
| Literal for meters (e.g., 100_m). | |
| template<char... Digits> | |
| constexpr quanta::spatial::kilometers | operator""_km () |
| Literal for kilometers (e.g., 5_km). | |
| template<char... Digits> | |
| constexpr quanta::spatial::mils | operator""_mil () |
| Literal for mils (e.g., 8_mil). | |
| template<char... Digits> | |
| constexpr quanta::spatial::inches | operator""_in () |
| Literal for inches (e.g., 12_in). | |
| template<char... Digits> | |
| constexpr quanta::spatial::feet | operator""_ft () |
| Literal for feet (e.g., 6_ft). | |
| template<char... Digits> | |
| constexpr quanta::spatial::yards | operator""_yd () |
| Literal for yards (e.g., 100_yd). | |
| template<char... Digits> | |
| constexpr quanta::spatial::miles | operator""_mi () |
| Literal for miles (e.g., 26_mi). | |
| template<char... Digits> | |
| constexpr quanta::spatial::nautical_miles | operator""_nmi () |
| Literal for nautical miles (e.g., 12_nmi). | |
| template<char... Digits> | |
| constexpr quanta::spatial::square_millimeters | operator""_mm2 () |
| Literal for square millimeters (e.g., 50_mm2). | |
| template<char... Digits> | |
| constexpr quanta::spatial::square_centimeters | operator""_cm2 () |
| Literal for square centimeters (e.g., 100_cm2). | |
| template<char... Digits> | |
| constexpr quanta::spatial::square_meters | operator""_m2 () |
| Literal for square meters (e.g., 12_m2). | |
| template<char... Digits> | |
| constexpr quanta::spatial::hectares | operator""_ha () |
| Literal for hectares (e.g., 3_ha). | |
| template<char... Digits> | |
| constexpr quanta::spatial::square_kilometers | operator""_km2 () |
| Literal for square kilometers (e.g., 5_km2). | |
| template<char... Digits> | |
| constexpr quanta::spatial::square_inches | operator""_in2 () |
| Literal for square inches (e.g., 144_in2). | |
| template<char... Digits> | |
| constexpr quanta::spatial::square_feet | operator""_ft2 () |
| Literal for square feet (e.g., 120_ft2). | |
| template<char... Digits> | |
| constexpr quanta::spatial::square_yards | operator""_yd2 () |
| Literal for square yards (e.g., 9_yd2). | |
| template<char... Digits> | |
| constexpr quanta::spatial::acres | operator""_ac () |
| Literal for acres (e.g., 40_ac). | |
| template<char... Digits> | |
| constexpr quanta::spatial::square_miles | operator""_mi2 () |
| Literal for square miles (e.g., 2_mi2). | |
| template<char... Digits> | |
| constexpr quanta::spatial::microliters | operator""_uL () |
| Literal for microliters (e.g., 50_uL). | |
| template<char... Digits> | |
| constexpr quanta::spatial::microliters | operator""_µL () |
| Literal for microliters (e.g., 50_µL). | |
| template<char... Digits> | |
| constexpr quanta::spatial::milliliters | operator""_mL () |
| Literal for milliliters (e.g., 250_mL). | |
| template<char... Digits> | |
| constexpr quanta::spatial::liters | operator""_L () |
| Literal for liters (e.g., 2_L). | |
| template<char... Digits> | |
| constexpr quanta::spatial::cubic_meters | operator""_m3 () |
| Literal for cubic meters (e.g., 3_m3). | |
| template<char... Digits> | |
| constexpr quanta::spatial::cubic_millimeters | operator""_mm3 () |
| Literal for cubic millimeters, i.e. | |
| template<char... Digits> | |
| constexpr quanta::spatial::cubic_centimeters | operator""_cm3 () |
| Literal for cubic centimeters, i.e. | |
| template<char... Digits> | |
| constexpr quanta::spatial::cubic_inches | operator""_in3 () |
| Literal for cubic inches (e.g., 231_in3). | |
| template<char... Digits> | |
| constexpr quanta::spatial::cubic_feet | operator""_ft3 () |
| Literal for cubic feet (e.g., 10_ft3). | |
| template<char... Digits> | |
| constexpr quanta::spatial::cubic_yards | operator""_yd3 () |
| Literal for cubic yards (e.g., 3_yd3). | |
| template<char... Digits> | |
| constexpr quanta::spatial::us_gallons | operator""_gal () |
| Literal for US gallons (e.g., 5_gal). | |
| template<char... Digits> | |
| constexpr quanta::thermo::celsius | operator""_c () |
| Literal for celsius (e.g., 25_c). | |
| template<char... Digits> | |
| constexpr quanta::thermo::decicelsius | operator""_dc () |
| Literal for decicelsius (e.g., 250_dc). | |
| template<char... Digits> | |
| constexpr quanta::thermo::millicelsius | operator""_mc () |
| Literal for millicelsius (e.g., 25000_mc). | |
| template<char... Digits> | |
| constexpr quanta::thermo::kelvin | operator""_k () |
| Literal for kelvin (e.g., 298_k). | |
| template<char... Digits> | |
| constexpr quanta::thermo::decikelvin | operator""_dk () |
| Literal for decikelvin (e.g., 2980_dk). | |
| template<char... Digits> | |
| constexpr quanta::thermo::millikelvin | operator""_mk () |
| Literal for millikelvin (e.g., 298000_mk). | |
| template<char... Digits> | |
| constexpr quanta::thermo::fahrenheit | operator""_f () |
| Literal for fahrenheit (e.g., 77_f). | |
| template<char... Digits> | |
| constexpr quanta::thermo::decifahrenheit | operator""_df () |
| Literal for decifahrenheit (e.g., 770_df). | |
| template<char... Digits> | |
| constexpr quanta::thermo::millifahrenheit | operator""_mf () |
| Literal for millifahrenheit (e.g., 77000_mf). | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_celsius | operator""_delta_c () |
Literal for delta_celsius (e.g., 5_delta_c); ASCII spelling of _Δc. | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_millicelsius | operator""_delta_mc () |
Literal for delta_millicelsius (e.g., 5000_delta_mc); ASCII spelling of _Δmc. | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_kelvin | operator""_delta_k () |
Literal for delta_kelvin (e.g., 5_delta_k); ASCII spelling of _Δk. | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_millikelvin | operator""_delta_mk () |
Literal for delta_millikelvin (e.g., 5000_delta_mk); ASCII spelling of _Δmk. | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_fahrenheit | operator""_delta_f () |
Literal for delta_fahrenheit (e.g., 9_delta_f); ASCII spelling of _Δf. | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_millifahrenheit | operator""_delta_mf () |
Literal for delta_millifahrenheit (e.g., 9000_delta_mf); ASCII spelling of _Δmf. | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_celsius | operator""_Δc () |
| Literal for delta_celsius (e.g., 5_Δc). | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_millicelsius | operator""_Δmc () |
| Literal for delta_millicelsius (e.g., 5000_Δmc). | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_kelvin | operator""_Δk () |
| Literal for delta_kelvin (e.g., 5_Δk). | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_millikelvin | operator""_Δmk () |
| Literal for delta_millikelvin (e.g., 5000_Δmk). | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_fahrenheit | operator""_Δf () |
| Literal for delta_fahrenheit (e.g., 9_Δf). | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_millifahrenheit | operator""_Δmf () |
| Literal for delta_millifahrenheit (e.g., 9000_Δmf). | |
Variables | |
| template<typename T > | |
| constexpr bool | treat_as_inexact_v = treat_as_inexact<T>::value |
| constexpr base_unit_t | base_unit {} |
| Selects the base-unit form in to_string(). | |
| constexpr scaled_t | scaled {} |
| Selects the scaled form in to_string(). | |
Type-safe units modeled after std::chrono.
User-defined literals for temperature types.
User-defined literals for spatial quantity types.
User-defined literals for frequency types.
User-defined literals for electrical quantity types.
Each domain lives in its own namespace: quanta::thermo (temperature), quanta::frequency (frequency), quanta::electro (electrical units and decibels) and quanta::spatial (length, area and volume). As with std::chrono, the literals of every domain are available through using namespace quanta::literals;, and each domain's through using namespace quanta::<domain>_literals; (e.g. quanta::frequency_literals) or using namespace quanta::<domain>;.
|
inlineconstexpr |
Selects the base-unit form in to_string().
The value is shown in the domain's base unit (e.g. °C, Hz, V, m), rendered in the shortest fixed notation that round-trips (never scientific), exactly as by the b format marker.
Definition at line 140 of file core.hpp.
Referenced by quanta::electro::to_string(), and quanta::electro::to_string().
Selects the scaled form in to_string().
The value is shown in the unit best suited to its magnitude, rendered in the shortest fixed notation that round-trips (never scientific), exactly as by the s format marker. See each domain's to_string() for the units it chooses between.
|
inlineconstexpr |