|
thermo 2.1.0
Type-safe temperature handling library modeled after std::chrono
|
#include <compare>#include <concepts>#include <cstdint>#include <limits>#include <ratio>#include <string>#include <version>#include <assert.h>Go to the source code of this file.
Classes | |
| struct | thermo::is_delta< _T > |
| Trait to detect delta specializations. More... | |
| struct | thermo::is_delta< delta< Rep, Precision > > |
| class | thermo::delta< Rep, Precision > |
| A temperature difference with a representation and precision. More... | |
| class | thermo::temperature< Scale, Delta > |
| An absolute temperature on a given scale. More... | |
Namespaces | |
| namespace | thermo |
| Temperature types and utilities. | |
| namespace | std |
| namespace | thermo_literals |
| User-defined literals for temperature types. | |
Macros | |
| #define | CONFIG_THERMO_STD_FORMAT 0 |
Typedefs | |
| using | thermo::delta_celsius = delta< int64_t > |
| Delta with 1 degree precision (Celsius/Kelvin). | |
| using | thermo::delta_decicelsius = delta< int64_t, std::deci > |
| Delta with 0.1 degree precision (Celsius/Kelvin). | |
| using | thermo::delta_millicelsius = delta< int64_t, std::milli > |
| Delta with 0.001 degree precision (Celsius/Kelvin). | |
| using | thermo::delta_kelvin = delta< int64_t > |
| Delta with 1 degree precision (Celsius/Kelvin). | |
| using | thermo::delta_decikelvin = delta< int64_t, std::deci > |
| Delta with 0.1 degree precision (Celsius/Kelvin). | |
| using | thermo::delta_millikelvin = delta< int64_t, std::milli > |
| Delta with 0.001 degree precision (Celsius/Kelvin). | |
| using | thermo::delta_fahrenheit = delta< int64_t, std::ratio< 5, 9 > > |
| Delta with 1°F precision. | |
| using | thermo::delta_decifahrenheit = delta< int64_t, std::ratio< 5, 90 > > |
| Delta with 0.1°F precision. | |
| using | thermo::delta_millifahrenheit = delta< int64_t, std::ratio< 5, 9000 > > |
| Delta with 0.001°F precision. | |
| using | thermo::celsius = temperature< celsius_scale > |
| Celsius with 1 degree precision. | |
| using | thermo::decicelsius = temperature< celsius_scale, delta< int64_t, std::deci > > |
| Celsius with 0.1 degree precision. | |
| using | thermo::millicelsius = temperature< celsius_scale, delta< int64_t, std::milli > > |
| Celsius with 0.001 degree precision. | |
| using | thermo::kelvin = temperature< kelvin_scale > |
| Kelvin with 1 degree precision. | |
| using | thermo::decikelvin = temperature< kelvin_scale, delta< int64_t, std::deci > > |
| Kelvin with 0.1 degree precision. | |
| using | thermo::millikelvin = temperature< kelvin_scale, delta< int64_t, std::milli > > |
| Kelvin with 0.001 degree precision. | |
| using | thermo::fahrenheit = temperature< fahrenheit_scale, delta< int64_t, std::ratio< 5, 9 > > > |
| Fahrenheit with 1 degree precision. | |
| using | thermo::decifahrenheit = temperature< fahrenheit_scale, delta< int64_t, std::ratio< 5, 90 > > > |
| Fahrenheit with 0.1 degree precision. | |
| using | 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 > | |
| constexpr ToDelta | 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 | 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 | 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 | 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 | thermo::round (const delta< Rep, Precision > &d) |
| Rounds a delta to the nearest representable value in the target precision. | |
| template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 > | |
| constexpr auto | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | thermo::operator<=> (const delta< Rep1, Precision1 > &lhs, const delta< Rep2, Precision2 > &rhs) |
| template<typename Rep , typename Precision > requires (!treat_as_inexact_v<Rep>) | |
| std::string | thermo::to_string (const delta< Rep, Precision > &d) |
| Renders a delta as its exact count with a precision-qualified unit, e.g. | |
| template<typename ToTemp , typename Scale , typename Delta > | |
| constexpr ToTemp | 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 | thermo::operator+ (const temperature< Scale, Delta1 > &lhs, const temperature< Scale, Delta2 > &rhs) -> temperature< Scale, std::common_type_t< Delta1, Delta2 > > |
| Adds two temperatures on the same scale. | |
| template<typename Scale , typename Delta1 , typename Delta2 > | |
| constexpr auto | thermo::operator- (const temperature< Scale, Delta1 > &lhs, const temperature< Scale, Delta2 > &rhs) -> temperature< Scale, std::common_type_t< Delta1, Delta2 > > |
| Subtracts two temperatures on the same scale. | |
| template<typename Scale , typename Delta1 , typename Delta2 > | |
| constexpr auto | 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 Rep2 , typename Precision2 > | |
| constexpr auto | 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 | 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 | 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 | 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 | thermo::operator<=> (const temperature< Scale, Delta1 > &lhs, const temperature< Scale, Delta2 > &rhs) |
| template<typename Scale , typename Rep , typename Precision > requires (!treat_as_inexact_v<Rep>) | |
| std::string | 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<char... Digits> | |
| constexpr thermo::celsius | thermo_literals::operator""_c () |
| Literal for celsius (e.g., 25_c). | |
| template<char... Digits> | |
| constexpr thermo::decicelsius | thermo_literals::operator""_dc () |
| Literal for decicelsius (e.g., 250_dc). | |
| template<char... Digits> | |
| constexpr thermo::millicelsius | thermo_literals::operator""_mc () |
| Literal for millicelsius (e.g., 25000_mc). | |
| template<char... Digits> | |
| constexpr thermo::kelvin | thermo_literals::operator""_k () |
| Literal for kelvin (e.g., 298_k). | |
| template<char... Digits> | |
| constexpr thermo::decikelvin | thermo_literals::operator""_dk () |
| Literal for decikelvin (e.g., 2980_dk). | |
| template<char... Digits> | |
| constexpr thermo::millikelvin | thermo_literals::operator""_mk () |
| Literal for millikelvin (e.g., 298000_mk). | |
| template<char... Digits> | |
| constexpr thermo::fahrenheit | thermo_literals::operator""_f () |
| Literal for fahrenheit (e.g., 77_f). | |
| template<char... Digits> | |
| constexpr thermo::decifahrenheit | thermo_literals::operator""_df () |
| Literal for decifahrenheit (e.g., 770_df). | |
| template<char... Digits> | |
| constexpr thermo::millifahrenheit | thermo_literals::operator""_mf () |
| Literal for millifahrenheit (e.g., 77000_mf). | |
| template<char... Digits> | |
| constexpr thermo::delta_celsius | thermo_literals::operator""_Δc () |
| Literal for delta_celsius (e.g., 5_Δc). | |
| template<char... Digits> | |
| constexpr thermo::delta_millicelsius | thermo_literals::operator""_Δmc () |
| Literal for delta_millicelsius (e.g., 5000_Δmc). | |
| template<char... Digits> | |
| constexpr thermo::delta_kelvin | thermo_literals::operator""_Δk () |
| Literal for delta_kelvin (e.g., 5_Δk). | |
| template<char... Digits> | |
| constexpr thermo::delta_millikelvin | thermo_literals::operator""_Δmk () |
| Literal for delta_millikelvin (e.g., 5000_Δmk). | |
| template<char... Digits> | |
| constexpr thermo::delta_fahrenheit | thermo_literals::operator""_Δf () |
| Literal for delta_fahrenheit (e.g., 9_Δf). | |
| template<char... Digits> | |
| constexpr thermo::delta_millifahrenheit | thermo_literals::operator""_Δmf () |
| Literal for delta_millifahrenheit (e.g., 9000_Δmf). | |
| #define CONFIG_THERMO_STD_FORMAT 0 |
Definition at line 19 of file thermo.hpp.