|
quanta 0.1.0
Type-safe units for temperature, frequency, electrical and spatial quantities, modeled after std::chrono
|
Temperature types and arithmetic, modeled after std::chrono. More...
#include <assert.h>#include <charconv>#include <compare>#include <concepts>#include <cstdint>#include <cstdlib>#include <limits>#include <quanta/core.hpp>#include <ratio>#include <string>#include <system_error>Go to the source code of this file.
Classes | |
| struct | quanta::thermo::is_delta< _T > |
| Trait to detect delta specializations. More... | |
| struct | quanta::thermo::is_delta< delta< Rep, Precision > > |
| class | quanta::thermo::delta< Rep, Precision > |
| A temperature difference with a representation and precision. More... | |
| class | quanta::thermo::temperature< Scale, Delta > |
| An absolute temperature on a given scale. More... | |
Namespaces | |
| namespace | quanta |
| Type-safe units modeled after std::chrono. | |
| namespace | quanta::thermo |
| Temperature types and utilities. | |
| namespace | std |
| namespace | quanta::literals |
| namespace | quanta::literals::thermo_literals |
Typedefs | |
| using | quanta::thermo::delta_celsius = delta< int64_t > |
| Delta with 1 degree precision (Celsius/Kelvin). | |
| using | quanta::thermo::delta_decicelsius = delta< int64_t, std::deci > |
| Delta with 0.1 degree precision (Celsius/Kelvin). | |
| using | quanta::thermo::delta_millicelsius = delta< int64_t, std::milli > |
| Delta with 0.001 degree precision (Celsius/Kelvin). | |
| using | quanta::thermo::delta_kelvin = delta< int64_t > |
| Delta with 1 degree precision (Celsius/Kelvin). | |
| using | quanta::thermo::delta_decikelvin = delta< int64_t, std::deci > |
| Delta with 0.1 degree precision (Celsius/Kelvin). | |
| using | quanta::thermo::delta_millikelvin = delta< int64_t, std::milli > |
| Delta with 0.001 degree precision (Celsius/Kelvin). | |
| using | quanta::thermo::delta_fahrenheit = delta< int64_t, std::ratio< 5, 9 > > |
| Delta with 1°F precision. | |
| using | quanta::thermo::delta_decifahrenheit = delta< int64_t, std::ratio< 5, 90 > > |
| Delta with 0.1°F precision. | |
| using | quanta::thermo::delta_millifahrenheit = delta< int64_t, std::ratio< 5, 9000 > > |
| Delta with 0.001°F precision. | |
| using | quanta::thermo::celsius = temperature< celsius_scale > |
| Celsius with 1 degree precision. | |
| using | quanta::thermo::decicelsius = temperature< celsius_scale, delta< int64_t, std::deci > > |
| Celsius with 0.1 degree precision. | |
| using | quanta::thermo::millicelsius = temperature< celsius_scale, delta< int64_t, std::milli > > |
| Celsius with 0.001 degree precision. | |
| using | quanta::thermo::kelvin = temperature< kelvin_scale > |
| Kelvin with 1 degree precision. | |
| using | quanta::thermo::decikelvin = temperature< kelvin_scale, delta< int64_t, std::deci > > |
| Kelvin with 0.1 degree precision. | |
| using | quanta::thermo::millikelvin = temperature< kelvin_scale, delta< int64_t, std::milli > > |
| Kelvin with 0.001 degree precision. | |
| using | quanta::thermo::fahrenheit = temperature< fahrenheit_scale, delta< int64_t, std::ratio< 5, 9 > > > |
| Fahrenheit with 1 degree precision. | |
| using | quanta::thermo::decifahrenheit = temperature< fahrenheit_scale, delta< int64_t, std::ratio< 5, 90 > > > |
| Fahrenheit with 0.1 degree precision. | |
| using | quanta::thermo::millifahrenheit = temperature< fahrenheit_scale, delta< int64_t, std::ratio< 5, 9000 > > > |
| Fahrenheit with 0.001 degree precision. | |
Functions | |
| template<typename ToDelta , typename Rep , typename Precision > requires detail::_quantity_cast_requirements<delta<Rep, Precision>, ToDelta> | |
| constexpr ToDelta | quanta::thermo::delta_cast (const delta< Rep, Precision > &d) |
| Converts a delta to a different precision or representation. | |
| template<typename ToDelta , typename Rep , typename Precision > | |
| constexpr ToDelta | quanta::thermo::ceil (const delta< Rep, Precision > &d) |
| Rounds a delta up to the nearest representable value in the target precision. | |
| template<typename ToDelta , typename Rep , typename Precision > | |
| constexpr ToDelta | quanta::thermo::floor (const delta< Rep, Precision > &d) |
| Rounds a delta down to the nearest representable value in the target precision. | |
| template<typename ToDelta , typename Rep , typename Precision > | |
| constexpr ToDelta | quanta::thermo::trunc (const delta< Rep, Precision > &d) |
| Rounds a delta toward zero to the nearest representable value in the target precision. | |
| template<typename ToDelta , typename Rep , typename Precision > | |
| constexpr ToDelta | quanta::thermo::round (const delta< Rep, Precision > &d) |
| Rounds a delta to the nearest representable value in the target precision. | |
| template<typename Rep , typename Precision > | |
| constexpr delta< Rep, Precision > | quanta::thermo::abs (const delta< Rep, Precision > &d) |
| Returns the absolute value of a delta. | |
| template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 > | |
| constexpr auto | quanta::thermo::operator+ (const delta< Rep1, Precision1 > &lhs, const delta< Rep2, Precision2 > &rhs) -> std::common_type_t< delta< Rep1, Precision1 >, delta< Rep2, Precision2 > > |
| Returns the sum of two deltas. | |
| template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 > | |
| constexpr auto | quanta::thermo::operator- (const delta< Rep1, Precision1 > &lhs, const delta< Rep2, Precision2 > &rhs) -> std::common_type_t< delta< Rep1, Precision1 >, delta< Rep2, Precision2 > > |
| Returns the difference of two deltas. | |
| template<typename Rep1 , typename Precision , typename Rep2 > requires not_delta<Rep2> && std::convertible_to<const Rep2&, std::common_type_t<Rep1, Rep2>> | |
| constexpr auto | quanta::thermo::operator* (const delta< Rep1, Precision > &d, const Rep2 &r) -> delta< std::common_type_t< Rep1, Rep2 >, Precision > |
| Multiplies a delta by a scalar. | |
| template<typename Rep1 , typename Rep2 , typename Precision > requires not_delta<Rep1> && std::convertible_to<const Rep1&, std::common_type_t<Rep1, Rep2>> | |
| constexpr auto | quanta::thermo::operator* (const Rep1 &r, const delta< Rep2, Precision > &d) -> delta< std::common_type_t< Rep1, Rep2 >, Precision > |
| Multiplies a scalar by a delta. | |
| template<typename Rep1 , typename Precision , typename Rep2 > requires not_delta<Rep2> && std::convertible_to<const Rep2&, std::common_type_t<Rep1, Rep2>> | |
| constexpr auto | quanta::thermo::operator/ (const delta< Rep1, Precision > &d, const Rep2 &s) -> delta< std::common_type_t< Rep1, Rep2 >, Precision > |
| Divides a delta by a scalar. | |
| template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 > | |
| constexpr auto | quanta::thermo::operator/ (const delta< Rep1, Precision1 > &lhs, const delta< Rep2, Precision2 > &rhs) -> std::common_type_t< Rep1, Rep2 > |
| Divides two deltas, returning a scalar. | |
| template<typename Rep1 , typename Precision , typename Rep2 > requires not_delta<Rep2> && std::convertible_to<const Rep2&, std::common_type_t<Rep1, Rep2>> && (!treat_as_inexact_v<Rep1> && !treat_as_inexact_v<Rep2>) | |
| constexpr auto | quanta::thermo::operator% (const delta< Rep1, Precision > &d, const Rep2 &s) -> delta< std::common_type_t< Rep1, Rep2 >, Precision > |
| Returns the remainder of dividing a delta by a scalar. | |
| template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 > requires (!treat_as_inexact_v<Rep1> && !treat_as_inexact_v<Rep2>) | |
| constexpr auto | quanta::thermo::operator% (const delta< Rep1, Precision1 > &lhs, const delta< Rep2, Precision2 > &rhs) -> std::common_type_t< delta< Rep1, Precision1 >, delta< Rep2, Precision2 > > |
| Returns the remainder of dividing two deltas. | |
| template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 > | |
| constexpr bool | quanta::thermo::operator== (const delta< Rep1, Precision1 > &lhs, const delta< Rep2, Precision2 > &rhs) |
| template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 > requires std::three_way_comparable<std::common_type_t<Rep1, Rep2>> | |
| constexpr auto | quanta::thermo::operator<=> (const delta< Rep1, Precision1 > &lhs, const delta< Rep2, Precision2 > &rhs) |
| template<typename Rep , typename Precision > | |
| std::string | quanta::thermo::to_string (const delta< Rep, Precision > &d) |
| Renders a delta as its exact count with a precision-qualified unit, e.g. | |
| template<typename Rep , typename Precision > | |
| std::string | quanta::thermo::to_string (const delta< Rep, Precision > &d, base_unit_t) |
| Renders a delta in its base unit (Δ°C or Δ°F), see base_unit, e.g. | |
| template<typename Rep , typename Precision > | |
| std::string | quanta::thermo::to_string (const delta< Rep, Precision > &d, scaled_t) |
| Renders a delta in its scaled form (its own unit), see scaled, e.g. | |
| template<typename ToTemp , typename Scale , typename Delta > requires _temperature_cast_requirements<Scale, Delta, typename ToTemp::scale, typename ToTemp::delta_type> | |
| constexpr ToTemp | quanta::thermo::temperature_cast (const temperature< Scale, Delta > &t) |
| Converts a temperature to a different scale or precision. | |
| template<typename Scale , typename Delta1 , typename Delta2 > | |
| constexpr auto | quanta::thermo::difference (const temperature< Scale, Delta1 > &lhs, const temperature< Scale, Delta2 > &rhs) -> std::common_type_t< Delta1, Delta2 > |
| Returns the difference between two temperatures as a delta. | |
| template<typename Scale , typename Delta1 , typename Delta2 > | |
| constexpr auto | quanta::thermo::operator- (const temperature< Scale, Delta1 > &lhs, const temperature< Scale, Delta2 > &rhs) -> std::common_type_t< Delta1, Delta2 > |
| Subtracts two temperatures on the same scale, giving the delta between them. | |
| template<typename Scale , typename Delta1 , typename Delta2 > | |
| void | quanta::thermo::operator+ (const temperature< Scale, Delta1 > &lhs, const temperature< Scale, Delta2 > &rhs)=delete |
| Adding two absolute temperatures is meaningless, and ill-formed. | |
| template<typename Scale , typename Delta1 , typename Rep2 , typename Precision2 > | |
| constexpr auto | quanta::thermo::operator+ (const temperature< Scale, Delta1 > &t, const delta< Rep2, Precision2 > &d) -> temperature< Scale, std::common_type_t< Delta1, delta< Rep2, Precision2 > > > |
| Adds a delta to a temperature. | |
| template<typename Rep1 , typename Precision1 , typename Scale , typename Delta2 > | |
| constexpr auto | quanta::thermo::operator+ (const delta< Rep1, Precision1 > &d, const temperature< Scale, Delta2 > &t) -> temperature< Scale, std::common_type_t< delta< Rep1, Precision1 >, Delta2 > > |
| Adds a temperature to a delta. | |
| template<typename Scale , typename Delta1 , typename Rep2 , typename Precision2 > | |
| constexpr auto | quanta::thermo::operator- (const temperature< Scale, Delta1 > &t, const delta< Rep2, Precision2 > &d) -> temperature< Scale, std::common_type_t< Delta1, delta< Rep2, Precision2 > > > |
| Subtracts a delta from a temperature. | |
| template<typename Scale , typename Delta1 , typename Delta2 > | |
| constexpr bool | quanta::thermo::operator== (const temperature< Scale, Delta1 > &lhs, const temperature< Scale, Delta2 > &rhs) |
| template<typename Scale , typename Delta1 , typename Delta2 > requires std::three_way_comparable<std::common_type_t<typename Delta1::rep, typename Delta2::rep>> | |
| constexpr auto | quanta::thermo::operator<=> (const temperature< Scale, Delta1 > &lhs, const temperature< Scale, Delta2 > &rhs) |
| template<typename Scale , typename Rep , typename Precision > | |
| std::string | quanta::thermo::to_string (const temperature< Scale, delta< Rep, Precision > > &t) |
| Renders a temperature as its exact count with a precision-qualified unit, e.g. | |
| template<typename Scale , typename Rep , typename Precision > | |
| std::string | quanta::thermo::to_string (const temperature< Scale, delta< Rep, Precision > > &t, base_unit_t) |
| Renders a temperature in the unprefixed degree of its own scale (°C, K or °F), see base_unit, e.g. | |
| template<typename Scale , typename Rep , typename Precision > | |
| std::string | quanta::thermo::to_string (const temperature< Scale, delta< Rep, Precision > > &t, scaled_t) |
| Renders a temperature in its scaled form (its own unit), see scaled, e.g. | |
| template<char... Digits> | |
| constexpr quanta::thermo::celsius | quanta::literals::thermo_literals::operator""_c () |
| Literal for celsius (e.g., 25_c). | |
| template<char... Digits> | |
| constexpr quanta::thermo::decicelsius | quanta::literals::thermo_literals::operator""_dc () |
| Literal for decicelsius (e.g., 250_dc). | |
| template<char... Digits> | |
| constexpr quanta::thermo::millicelsius | quanta::literals::thermo_literals::operator""_mc () |
| Literal for millicelsius (e.g., 25000_mc). | |
| template<char... Digits> | |
| constexpr quanta::thermo::kelvin | quanta::literals::thermo_literals::operator""_k () |
| Literal for kelvin (e.g., 298_k). | |
| template<char... Digits> | |
| constexpr quanta::thermo::decikelvin | quanta::literals::thermo_literals::operator""_dk () |
| Literal for decikelvin (e.g., 2980_dk). | |
| template<char... Digits> | |
| constexpr quanta::thermo::millikelvin | quanta::literals::thermo_literals::operator""_mk () |
| Literal for millikelvin (e.g., 298000_mk). | |
| template<char... Digits> | |
| constexpr quanta::thermo::fahrenheit | quanta::literals::thermo_literals::operator""_f () |
| Literal for fahrenheit (e.g., 77_f). | |
| template<char... Digits> | |
| constexpr quanta::thermo::decifahrenheit | quanta::literals::thermo_literals::operator""_df () |
| Literal for decifahrenheit (e.g., 770_df). | |
| template<char... Digits> | |
| constexpr quanta::thermo::millifahrenheit | quanta::literals::thermo_literals::operator""_mf () |
| Literal for millifahrenheit (e.g., 77000_mf). | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_celsius | quanta::literals::thermo_literals::operator""_delta_c () |
Literal for delta_celsius (e.g., 5_delta_c); ASCII spelling of _Δc. | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_millicelsius | quanta::literals::thermo_literals::operator""_delta_mc () |
Literal for delta_millicelsius (e.g., 5000_delta_mc); ASCII spelling of _Δmc. | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_kelvin | quanta::literals::thermo_literals::operator""_delta_k () |
Literal for delta_kelvin (e.g., 5_delta_k); ASCII spelling of _Δk. | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_millikelvin | quanta::literals::thermo_literals::operator""_delta_mk () |
Literal for delta_millikelvin (e.g., 5000_delta_mk); ASCII spelling of _Δmk. | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_fahrenheit | quanta::literals::thermo_literals::operator""_delta_f () |
Literal for delta_fahrenheit (e.g., 9_delta_f); ASCII spelling of _Δf. | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_millifahrenheit | quanta::literals::thermo_literals::operator""_delta_mf () |
Literal for delta_millifahrenheit (e.g., 9000_delta_mf); ASCII spelling of _Δmf. | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_celsius | quanta::literals::thermo_literals::operator""_Δc () |
| Literal for delta_celsius (e.g., 5_Δc). | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_millicelsius | quanta::literals::thermo_literals::operator""_Δmc () |
| Literal for delta_millicelsius (e.g., 5000_Δmc). | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_kelvin | quanta::literals::thermo_literals::operator""_Δk () |
| Literal for delta_kelvin (e.g., 5_Δk). | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_millikelvin | quanta::literals::thermo_literals::operator""_Δmk () |
| Literal for delta_millikelvin (e.g., 5000_Δmk). | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_fahrenheit | quanta::literals::thermo_literals::operator""_Δf () |
| Literal for delta_fahrenheit (e.g., 9_Δf). | |
| template<char... Digits> | |
| constexpr quanta::thermo::delta_millifahrenheit | quanta::literals::thermo_literals::operator""_Δmf () |
| Literal for delta_millifahrenheit (e.g., 9000_Δmf). | |
Temperature types and arithmetic, modeled after std::chrono.
Definition in file thermo.hpp.