quanta 0.1.0
Type-safe units for temperature, frequency, electrical and spatial quantities, modeled after std::chrono
Loading...
Searching...
No Matches
quanta::thermo Namespace Reference

Temperature types and utilities. More...

Classes

class  delta
 A temperature difference with a representation and precision. More...
 
struct  is_delta
 Trait to detect delta specializations. More...
 
struct  is_delta< delta< Rep, Precision > >
 
class  temperature
 An absolute temperature on a given scale. More...
 

Typedefs

using delta_celsius = delta< int64_t >
 Delta with 1 degree precision (Celsius/Kelvin).
 
using delta_decicelsius = delta< int64_t, std::deci >
 Delta with 0.1 degree precision (Celsius/Kelvin).
 
using delta_millicelsius = delta< int64_t, std::milli >
 Delta with 0.001 degree precision (Celsius/Kelvin).
 
using delta_kelvin = delta< int64_t >
 Delta with 1 degree precision (Celsius/Kelvin).
 
using delta_decikelvin = delta< int64_t, std::deci >
 Delta with 0.1 degree precision (Celsius/Kelvin).
 
using delta_millikelvin = delta< int64_t, std::milli >
 Delta with 0.001 degree precision (Celsius/Kelvin).
 
using delta_fahrenheit = delta< int64_t, std::ratio< 5, 9 > >
 Delta with 1°F precision.
 
using delta_decifahrenheit = delta< int64_t, std::ratio< 5, 90 > >
 Delta with 0.1°F precision.
 
using delta_millifahrenheit = delta< int64_t, std::ratio< 5, 9000 > >
 Delta with 0.001°F precision.
 
using celsius = temperature< celsius_scale >
 Celsius with 1 degree precision.
 
using decicelsius = temperature< celsius_scale, delta< int64_t, std::deci > >
 Celsius with 0.1 degree precision.
 
using millicelsius = temperature< celsius_scale, delta< int64_t, std::milli > >
 Celsius with 0.001 degree precision.
 
using kelvin = temperature< kelvin_scale >
 Kelvin with 1 degree precision.
 
using decikelvin = temperature< kelvin_scale, delta< int64_t, std::deci > >
 Kelvin with 0.1 degree precision.
 
using millikelvin = temperature< kelvin_scale, delta< int64_t, std::milli > >
 Kelvin with 0.001 degree precision.
 
using fahrenheit = temperature< fahrenheit_scale, delta< int64_t, std::ratio< 5, 9 > > >
 Fahrenheit with 1 degree precision.
 
using decifahrenheit = temperature< fahrenheit_scale, delta< int64_t, std::ratio< 5, 90 > > >
 Fahrenheit with 0.1 degree precision.
 
using 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 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 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 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 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 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 > abs (const delta< Rep, Precision > &d)
 Returns the absolute value of a delta.
 
template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 >
constexpr auto 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 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 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 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 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 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 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 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 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 operator<=> (const delta< Rep1, Precision1 > &lhs, const delta< Rep2, Precision2 > &rhs)
 
template<typename Rep , typename Precision >
std::string 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 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 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 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 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 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 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 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 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 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 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 operator<=> (const temperature< Scale, Delta1 > &lhs, const temperature< Scale, Delta2 > &rhs)
 
template<typename Scale , typename Rep , typename Precision >
std::string 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 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 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.
 

Detailed Description

Temperature types and utilities.

This library provides type-safe temperature handling with support for multiple scales (Celsius, Kelvin, Fahrenheit) and precisions, following the design of std::chrono. It distinguishes between absolute temperatures and temperature differences (deltas).

Formatting

to_string() and std::format show a temperature or delta in its own unit by default, whatever the format spec: {} prints the exact count and {:.1f} the count as a double, each followed by the precision-qualified unit. A single leading marker letter in the spec, or a tag argument to to_string(), opts into a different unit:

std::format("{}", millicelsius(22534)); // "22534m°C" own unit
std::format("{:.1f}", millicelsius(22534)); // "22534.0m°C"
std::format("{:b}", millicelsius(22534)); // "22.534°C" base unit
std::format("{:b.1f}", millicelsius(22534)); // "22.5°C"
std::format("{:b.1f}", delta_millicelsius(1500)); // "1.5Δ°C"
to_string(millicelsius(22534), base_unit); // "22.534°C"
temperature< celsius_scale, delta< int64_t, std::milli > > millicelsius
Celsius with 0.001 degree precision.
Definition thermo.hpp:1157
delta< int64_t, std::milli > delta_millicelsius
Delta with 0.001 degree precision (Celsius/Kelvin).
Definition thermo.hpp:450
std::string to_string(const delta< Rep, Precision > &d)
Renders a delta as its exact count with a precision-qualified unit, e.g.
Definition thermo.hpp:664

The base unit is the unprefixed degree of the same scale (m°C -> °C, mK -> K, m°F -> °F); temperatures are never converted to another scale. The scaled form (s, see scaled) keeps the type's own unit: temperatures are not rescaled to suit their magnitude.

Typedef Documentation

◆ celsius

using quanta::thermo::celsius = typedef temperature<celsius_scale>

Celsius with 1 degree precision.

Definition at line 1153 of file thermo.hpp.

◆ decicelsius

using quanta::thermo::decicelsius = typedef temperature<celsius_scale, delta<int64_t, std::deci> >

Celsius with 0.1 degree precision.

Definition at line 1155 of file thermo.hpp.

◆ decifahrenheit

using quanta::thermo::decifahrenheit = typedef temperature<fahrenheit_scale, delta<int64_t, std::ratio<5, 90> >>

Fahrenheit with 0.1 degree precision.

Definition at line 1167 of file thermo.hpp.

◆ decikelvin

using quanta::thermo::decikelvin = typedef temperature<kelvin_scale, delta<int64_t, std::deci> >

Kelvin with 0.1 degree precision.

Definition at line 1161 of file thermo.hpp.

◆ delta_celsius

using quanta::thermo::delta_celsius = typedef delta<int64_t>

Delta with 1 degree precision (Celsius/Kelvin).

Definition at line 446 of file thermo.hpp.

◆ delta_decicelsius

using quanta::thermo::delta_decicelsius = typedef delta<int64_t, std::deci>

Delta with 0.1 degree precision (Celsius/Kelvin).

Definition at line 448 of file thermo.hpp.

◆ delta_decifahrenheit

using quanta::thermo::delta_decifahrenheit = typedef delta<int64_t, std::ratio<5, 90> >

Delta with 0.1°F precision.

Definition at line 460 of file thermo.hpp.

◆ delta_decikelvin

using quanta::thermo::delta_decikelvin = typedef delta<int64_t, std::deci>

Delta with 0.1 degree precision (Celsius/Kelvin).

Definition at line 454 of file thermo.hpp.

◆ delta_fahrenheit

using quanta::thermo::delta_fahrenheit = typedef delta<int64_t, std::ratio<5, 9> >

Delta with 1°F precision.

Definition at line 458 of file thermo.hpp.

◆ delta_kelvin

using quanta::thermo::delta_kelvin = typedef delta<int64_t>

Delta with 1 degree precision (Celsius/Kelvin).

Definition at line 452 of file thermo.hpp.

◆ delta_millicelsius

using quanta::thermo::delta_millicelsius = typedef delta<int64_t, std::milli>

Delta with 0.001 degree precision (Celsius/Kelvin).

Definition at line 450 of file thermo.hpp.

◆ delta_millifahrenheit

using quanta::thermo::delta_millifahrenheit = typedef delta<int64_t, std::ratio<5, 9000> >

Delta with 0.001°F precision.

Definition at line 462 of file thermo.hpp.

◆ delta_millikelvin

using quanta::thermo::delta_millikelvin = typedef delta<int64_t, std::milli>

Delta with 0.001 degree precision (Celsius/Kelvin).

Definition at line 456 of file thermo.hpp.

◆ fahrenheit

using quanta::thermo::fahrenheit = typedef temperature<fahrenheit_scale, delta<int64_t, std::ratio<5, 9> >>

Fahrenheit with 1 degree precision.

Definition at line 1165 of file thermo.hpp.

◆ kelvin

using quanta::thermo::kelvin = typedef temperature<kelvin_scale>

Kelvin with 1 degree precision.

Definition at line 1159 of file thermo.hpp.

◆ millicelsius

using quanta::thermo::millicelsius = typedef temperature<celsius_scale, delta<int64_t, std::milli> >

Celsius with 0.001 degree precision.

Definition at line 1157 of file thermo.hpp.

◆ millifahrenheit

using quanta::thermo::millifahrenheit = typedef temperature<fahrenheit_scale, delta<int64_t, std::ratio<5, 9000> >>

Fahrenheit with 0.001 degree precision.

Definition at line 1169 of file thermo.hpp.

◆ millikelvin

using quanta::thermo::millikelvin = typedef temperature<kelvin_scale, delta<int64_t, std::milli> >

Kelvin with 0.001 degree precision.

Definition at line 1163 of file thermo.hpp.

Function Documentation

◆ abs()

template<typename Rep , typename Precision >
constexpr delta< Rep, Precision > quanta::thermo::abs ( const delta< Rep, Precision > &  d)
constexpr

Returns the absolute value of a delta.

Template Parameters
RepRepresentation type.
PrecisionPrecision type.
Parameters
dThe delta.
Returns
The absolute value of the delta.
using namespace quanta::thermo;
auto a = abs(delta_millicelsius(-1500)); // delta_millicelsius(1500)
Temperature types and utilities.
Definition thermo.hpp:50
constexpr delta< Rep, Precision > abs(const delta< Rep, Precision > &d)
Returns the absolute value of a delta.
Definition thermo.hpp:359

Definition at line 359 of file thermo.hpp.

◆ ceil()

template<typename ToDelta , typename Rep , typename Precision >
constexpr ToDelta quanta::thermo::ceil ( const delta< Rep, Precision > &  d)
constexpr

Rounds a delta up to the nearest representable value in the target precision.

Returns the smallest value of type ToDelta that is greater than or equal to d. When converting to the same or finer precision, returns the exact conversion. A target whose rep is not integral (such as a floating-point one) is not rounded: the result is delta_cast<ToDelta>(d).

As with the cast, the result is undefined if it does not fit the target rep.

Template Parameters
ToDeltaTarget delta type.
RepSource representation type.
PrecisionSource precision.
Parameters
dThe delta to round.
Returns
The rounded delta.

Definition at line 282 of file thermo.hpp.

◆ delta_cast()

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)
constexpr

Converts a delta to a different precision or representation.

For integer-to-integer conversions, this function uses wider intermediate types (128-bit when available) to minimize overflow risk during ratio arithmetic.

Template Parameters
ToDeltaThe target delta type.
RepSource representation type.
PrecisionSource precision.
Parameters
dThe delta to convert.
Returns
The converted delta.

Definition at line 261 of file thermo.hpp.

◆ difference()

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>
constexpr

Returns the difference between two temperatures as a delta.

The same as lhs - rhs.

Parameters
lhsFirst temperature.
rhsSecond temperature.
Returns
lhs - rhs as a delta.

Definition at line 1091 of file thermo.hpp.

References quanta::thermo::delta< Rep, Precision >::count().

Referenced by operator-().

◆ floor()

template<typename ToDelta , typename Rep , typename Precision >
constexpr ToDelta quanta::thermo::floor ( const delta< Rep, Precision > &  d)
constexpr

Rounds a delta down to the nearest representable value in the target precision.

Returns the largest value of type ToDelta that is less than or equal to d. When converting to the same or finer precision, returns the exact conversion. A target whose rep is not integral (such as a floating-point one) is not rounded: the result is delta_cast<ToDelta>(d).

As with the cast, the result is undefined if it does not fit the target rep.

Template Parameters
ToDeltaTarget delta type.
RepSource representation type.
PrecisionSource precision.
Parameters
dThe delta to round.
Returns
The rounded delta.

Definition at line 303 of file thermo.hpp.

◆ operator%() [1/2]

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>
constexpr

Returns the remainder of dividing a delta by a scalar.

Definition at line 417 of file thermo.hpp.

◆ operator%() [2/2]

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>>
constexpr

Returns the remainder of dividing two deltas.

Definition at line 426 of file thermo.hpp.

◆ operator*() [1/2]

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>
constexpr

Multiplies a delta by a scalar.

Definition at line 382 of file thermo.hpp.

◆ operator*() [2/2]

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>
constexpr

Multiplies a scalar by a delta.

Definition at line 391 of file thermo.hpp.

◆ operator+() [1/4]

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>>
constexpr

Adds a temperature to a delta.

Definition at line 1128 of file thermo.hpp.

◆ operator+() [2/4]

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>>
constexpr

Returns the sum of two deltas.

Definition at line 365 of file thermo.hpp.

◆ operator+() [3/4]

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.

Add a delta to a temperature instead (celsius(20) + delta_celsius(5)).

◆ operator+() [4/4]

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>>>
constexpr

Adds a delta to a temperature.

Definition at line 1120 of file thermo.hpp.

References quanta::thermo::temperature< Scale, Delta >::count().

◆ operator-() [1/3]

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>>
constexpr

Returns the difference of two deltas.

Definition at line 373 of file thermo.hpp.

◆ operator-() [2/3]

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>
constexpr

Subtracts two temperatures on the same scale, giving the delta between them.

As with std::chrono::time_point, the difference of two absolute points is a delta, not a temperature: celsius(25) - celsius(20) == delta_celsius(5). Equivalent to difference(lhs, rhs).

Definition at line 1105 of file thermo.hpp.

References difference().

◆ operator-() [3/3]

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>>>
constexpr

Subtracts a delta from a temperature.

Definition at line 1135 of file thermo.hpp.

References quanta::thermo::temperature< Scale, Delta >::count().

◆ operator/() [1/2]

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>
constexpr

Divides a delta by a scalar.

Definition at line 399 of file thermo.hpp.

◆ operator/() [2/2]

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>
constexpr

Divides two deltas, returning a scalar.

Definition at line 407 of file thermo.hpp.

References quanta::thermo::delta< Rep, Precision >::count().

◆ operator<=>() [1/2]

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 
)
constexpr

Definition at line 440 of file thermo.hpp.

References quanta::thermo::delta< Rep, Precision >::count().

◆ operator<=>() [2/2]

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 
)
constexpr

Definition at line 1148 of file thermo.hpp.

References quanta::thermo::temperature< Scale, Delta >::count().

◆ operator==() [1/2]

template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 >
constexpr bool quanta::thermo::operator== ( const delta< Rep1, Precision1 > &  lhs,
const delta< Rep2, Precision2 > &  rhs 
)
constexpr

Definition at line 433 of file thermo.hpp.

References quanta::thermo::delta< Rep, Precision >::count().

◆ operator==() [2/2]

template<typename Scale , typename Delta1 , typename Delta2 >
constexpr bool quanta::thermo::operator== ( const temperature< Scale, Delta1 > &  lhs,
const temperature< Scale, Delta2 > &  rhs 
)
constexpr

Definition at line 1142 of file thermo.hpp.

References quanta::thermo::temperature< Scale, Delta >::count().

◆ round()

template<typename ToDelta , typename Rep , typename Precision >
constexpr ToDelta quanta::thermo::round ( const delta< Rep, Precision > &  d)
constexpr

Rounds a delta to the nearest representable value in the target precision.

Returns the value of type ToDelta that is nearest to d. When exactly halfway between two values, rounds to the even one, as std::chrono::round does. When converting to the same or finer precision, returns the exact conversion.

As with the cast, the result is undefined if it does not fit the target rep.

Template Parameters
ToDeltaTarget delta type.
RepSource representation type.
PrecisionSource precision.
Parameters
dThe delta to round.
Returns
The rounded delta.

Definition at line 340 of file thermo.hpp.

◆ temperature_cast()

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)
constexpr

Converts a temperature to a different scale or precision.

For integer-to-integer conversions, this function uses wider intermediate types (128-bit when available) to minimize overflow risk during ratio arithmetic. Across scales the intermediate is signed even for unsigned reps, so a negative offset between the scales does not wrap; as with any cast, a result outside the target rep's range is the caller's concern. Without 128-bit integer support (e.g. MSVC, 32-bit targets such as the ESP32), cross-scale integral conversions of counts near the 64-bit limits can overflow the intermediate.

Template Parameters
ToTempThe target temperature type.
ScaleSource scale.
DeltaSource delta type.
Parameters
tThe temperature to convert.
Returns
The converted temperature.

Definition at line 934 of file thermo.hpp.

◆ to_string() [1/6]

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.

to_string(delta_millicelsius(1500)) == "1500Δm°C".

Floating-point counts are rendered in the shortest fixed notation that round-trips, as by {} in std::format.

Definition at line 664 of file thermo.hpp.

References quanta::thermo::delta< Rep, Precision >::count().

◆ to_string() [2/6]

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.

to_string(delta_millicelsius(1500), base_unit) == "1.5Δ°C".

Definition at line 673 of file thermo.hpp.

References quanta::thermo::delta< Rep, Precision >::count().

◆ to_string() [3/6]

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.

to_string(delta_millicelsius(1500), scaled) == "1500Δm°C".

Definition at line 683 of file thermo.hpp.

References quanta::thermo::delta< Rep, Precision >::count().

◆ to_string() [4/6]

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.

to_string(millicelsius(22500)) == "22500m°C".

Floating-point counts are rendered in the shortest fixed notation that round-trips, as by {} in std::format.

Definition at line 1189 of file thermo.hpp.

References quanta::thermo::temperature< Scale, Delta >::count().

◆ to_string() [5/6]

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.

to_string(millicelsius(22534), base_unit) == "22.534°C".

Definition at line 1199 of file thermo.hpp.

References quanta::thermo::temperature< Scale, Delta >::count().

◆ to_string() [6/6]

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.

to_string(millicelsius(22534), scaled) == "22534m°C".

Definition at line 1209 of file thermo.hpp.

References quanta::thermo::temperature< Scale, Delta >::count().

◆ trunc()

template<typename ToDelta , typename Rep , typename Precision >
constexpr ToDelta quanta::thermo::trunc ( const delta< Rep, Precision > &  d)
constexpr

Rounds a delta toward zero to the nearest representable value in the target precision.

Returns the value of type ToDelta that is closest to zero. When converting to the same or finer precision, returns the exact conversion.

Template Parameters
ToDeltaTarget delta type.
RepSource representation type.
PrecisionSource precision.
Parameters
dThe delta to round.
Returns
The rounded delta.

Definition at line 320 of file thermo.hpp.