quanta 0.1.0
Type-safe units for temperature, frequency, electrical and spatial quantities, modeled after std::chrono
Loading...
Searching...
No Matches
quanta::thermo::temperature< Scale, Delta > Class Template Reference

An absolute temperature on a given scale. More...

#include <quanta/thermo.hpp>

Public Types

using scale = Scale
 The temperature scale.
 
using delta_type = Delta
 The delta type.
 
using rep = typename Delta::rep
 The representation type.
 

Public Member Functions

constexpr temperature ()=default
 Constructs a temperature at the scale's zero point.
 
 temperature (const temperature &)=default
 
template<typename Rep2 >
requires std::convertible_to<const Rep2&, rep> && (treat_as_inexact_v<rep> || !treat_as_inexact_v<Rep2>)
constexpr temperature (const Rep2 &r)
 Constructs from a tick count.
 
constexpr temperature (const Delta &d)
 Constructs from a delta.
 
template<typename Delta2 >
requires (!std::is_same_v<Delta, Delta2>) && _temperature_castable<temperature<Scale, Delta2>, temperature> && _implicit_temperature_conversion<Scale, Delta2, Scale, Delta>
constexpr temperature (const temperature< Scale, Delta2 > &t)
 
template<typename Delta2 >
requires (!std::is_same_v<Delta, Delta2>) && _temperature_castable<temperature<Scale, Delta2>, temperature> && (!_implicit_temperature_conversion<Scale, Delta2, Scale, Delta>)
constexpr temperature (const temperature< Scale, Delta2 > &t)
 
template<typename Scale2 , typename Delta2 >
requires (!std::is_same_v<temperature, temperature<Scale2, Delta2>>) && _temperature_castable<temperature<Scale2, Delta2>, temperature> && _implicit_temperature_conversion<Scale2, Delta2, Scale, Delta>
constexpr temperature (const temperature< Scale2, Delta2 > &t)
 
template<typename Scale2 , typename Delta2 >
requires (!std::is_same_v<temperature, temperature<Scale2, Delta2>>) && _temperature_castable<temperature<Scale2, Delta2>, temperature> && (!_implicit_temperature_conversion<Scale2, Delta2, Scale, Delta>)
constexpr temperature (const temperature< Scale2, Delta2 > &t)
 
 ~temperature ()=default
 
temperature & operator= (const temperature &)=default
 
constexpr rep count () const
 Returns the tick count.
 
constexpr temperature & operator++ ()
 
constexpr temperature operator++ (int)
 
constexpr temperature & operator-- ()
 
constexpr temperature operator-- (int)
 
constexpr temperature operator- () const
 Negates the temperature (e.g.
 
template<typename Rep2 , typename Precision2 >
constexpr temperature & operator+= (const delta< Rep2, Precision2 > &d)
 
template<typename Rep2 , typename Precision2 >
constexpr temperature & operator-= (const delta< Rep2, Precision2 > &d)
 

Static Public Member Functions

static constexpr temperature min () noexcept
 Returns the minimum representable temperature.
 
static constexpr temperature max () noexcept
 Returns the maximum representable temperature.
 

Detailed Description

template<typename Scale, typename Delta>
class quanta::thermo::temperature< Scale, Delta >

An absolute temperature on a given scale.

Similar to std::chrono::time_point, temperature represents an absolute point on a temperature scale. The scale defines the zero point (offset from absolute zero), and the delta type defines the precision.

As with time_point, a temperature plus or minus a delta is a temperature, and the difference of two temperatures is a delta. Adding two temperatures is ill-formed.

celsius room{20};
auto warmer = room + delta_celsius(5); // celsius(25)
auto rise = warmer - room; // delta_celsius(5)
delta< int64_t > delta_celsius
Delta with 1 degree precision (Celsius/Kelvin).
Definition thermo.hpp:446
temperature< celsius_scale > celsius
Celsius with 1 degree precision.
Definition thermo.hpp:1153
Template Parameters
ScaleThe temperature scale (celsius_scale, kelvin_scale, fahrenheit_scale).
DeltaThe delta type for precision (default: delta<int64_t>).

Definition at line 959 of file thermo.hpp.

Member Typedef Documentation

◆ delta_type

template<typename Scale , typename Delta >
using quanta::thermo::temperature< Scale, Delta >::delta_type = Delta

The delta type.

Definition at line 966 of file thermo.hpp.

◆ rep

template<typename Scale , typename Delta >
using quanta::thermo::temperature< Scale, Delta >::rep = typename Delta::rep

The representation type.

Definition at line 968 of file thermo.hpp.

◆ scale

template<typename Scale , typename Delta >
using quanta::thermo::temperature< Scale, Delta >::scale = Scale

The temperature scale.

Definition at line 964 of file thermo.hpp.

Constructor & Destructor Documentation

◆ temperature() [1/8]

◆ temperature() [2/8]

template<typename Scale , typename Delta >
quanta::thermo::temperature< Scale, Delta >::temperature ( const temperature< Scale, Delta > &  )
default

◆ temperature() [3/8]

template<typename Scale , typename Delta >
template<typename Rep2 >
requires std::convertible_to<const Rep2&, rep> && (treat_as_inexact_v<rep> || !treat_as_inexact_v<Rep2>)
constexpr quanta::thermo::temperature< Scale, Delta >::temperature ( const Rep2 &  r)
inlineexplicitconstexpr

Constructs from a tick count.

Template Parameters
Rep2The source representation type.
Parameters
rThe tick count in scale units.

Definition at line 981 of file thermo.hpp.

◆ temperature() [4/8]

template<typename Scale , typename Delta >
constexpr quanta::thermo::temperature< Scale, Delta >::temperature ( const Delta &  d)
inlineexplicitconstexpr

Constructs from a delta.

Parameters
dThe delta from the scale's zero point.

Definition at line 988 of file thermo.hpp.

◆ temperature() [5/8]

template<typename Scale , typename Delta >
template<typename Delta2 >
requires (!std::is_same_v<Delta, Delta2>) && _temperature_castable<temperature<Scale, Delta2>, temperature> && _implicit_temperature_conversion<Scale, Delta2, Scale, Delta>
constexpr quanta::thermo::temperature< Scale, Delta >::temperature ( const temperature< Scale, Delta2 > &  t)
inlineconstexpr

Definition at line 999 of file thermo.hpp.

◆ temperature() [6/8]

template<typename Scale , typename Delta >
template<typename Delta2 >
requires (!std::is_same_v<Delta, Delta2>) && _temperature_castable<temperature<Scale, Delta2>, temperature> && (!_implicit_temperature_conversion<Scale, Delta2, Scale, Delta>)
constexpr quanta::thermo::temperature< Scale, Delta >::temperature ( const temperature< Scale, Delta2 > &  t)
inlineexplicitconstexpr

Definition at line 1006 of file thermo.hpp.

◆ temperature() [7/8]

template<typename Scale , typename Delta >
template<typename Scale2 , typename Delta2 >
requires (!std::is_same_v<temperature, temperature<Scale2, Delta2>>) && _temperature_castable<temperature<Scale2, Delta2>, temperature> && _implicit_temperature_conversion<Scale2, Delta2, Scale, Delta>
constexpr quanta::thermo::temperature< Scale, Delta >::temperature ( const temperature< Scale2, Delta2 > &  t)
inlineconstexpr

Definition at line 1014 of file thermo.hpp.

◆ temperature() [8/8]

template<typename Scale , typename Delta >
template<typename Scale2 , typename Delta2 >
requires (!std::is_same_v<temperature, temperature<Scale2, Delta2>>) && _temperature_castable<temperature<Scale2, Delta2>, temperature> && (!_implicit_temperature_conversion<Scale2, Delta2, Scale, Delta>)
constexpr quanta::thermo::temperature< Scale, Delta >::temperature ( const temperature< Scale2, Delta2 > &  t)
inlineexplicitconstexpr

Definition at line 1022 of file thermo.hpp.

◆ ~temperature()

template<typename Scale , typename Delta >
quanta::thermo::temperature< Scale, Delta >::~temperature ( )
default

Member Function Documentation

◆ count()

template<typename Scale , typename Delta >
constexpr rep quanta::thermo::temperature< Scale, Delta >::count ( ) const
inlineconstexpr

◆ max()

template<typename Scale , typename Delta >
static constexpr temperature quanta::thermo::temperature< Scale, Delta >::max ( )
inlinestaticconstexprnoexcept

Returns the maximum representable temperature.

Definition at line 1074 of file thermo.hpp.

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

◆ min()

template<typename Scale , typename Delta >
static constexpr temperature quanta::thermo::temperature< Scale, Delta >::min ( )
inlinestaticconstexprnoexcept

Returns the minimum representable temperature.

Definition at line 1071 of file thermo.hpp.

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

◆ operator++() [1/2]

template<typename Scale , typename Delta >
constexpr temperature & quanta::thermo::temperature< Scale, Delta >::operator++ ( )
inlineconstexpr

Definition at line 1031 of file thermo.hpp.

◆ operator++() [2/2]

template<typename Scale , typename Delta >
constexpr temperature quanta::thermo::temperature< Scale, Delta >::operator++ ( int  )
inlineconstexpr

◆ operator+=()

template<typename Scale , typename Delta >
template<typename Rep2 , typename Precision2 >
constexpr temperature & quanta::thermo::temperature< Scale, Delta >::operator+= ( const delta< Rep2, Precision2 > &  d)
inlineconstexpr

Definition at line 1059 of file thermo.hpp.

◆ operator-()

template<typename Scale , typename Delta >
constexpr temperature quanta::thermo::temperature< Scale, Delta >::operator- ( ) const
inlineconstexpr

Negates the temperature (e.g.

to write -123_dc as -(123_dc)).

Only available on relative scales such as Celsius and Fahrenheit; on an absolute scale (Kelvin) negation would fall below absolute zero and is a compile error.

Definition at line 1052 of file thermo.hpp.

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

◆ operator--() [1/2]

template<typename Scale , typename Delta >
constexpr temperature & quanta::thermo::temperature< Scale, Delta >::operator-- ( )
inlineconstexpr

Definition at line 1038 of file thermo.hpp.

◆ operator--() [2/2]

template<typename Scale , typename Delta >
constexpr temperature quanta::thermo::temperature< Scale, Delta >::operator-- ( int  )
inlineconstexpr

◆ operator-=()

template<typename Scale , typename Delta >
template<typename Rep2 , typename Precision2 >
constexpr temperature & quanta::thermo::temperature< Scale, Delta >::operator-= ( const delta< Rep2, Precision2 > &  d)
inlineconstexpr

Definition at line 1065 of file thermo.hpp.

◆ operator=()

template<typename Scale , typename Delta >
temperature & quanta::thermo::temperature< Scale, Delta >::operator= ( const temperature< Scale, Delta > &  )
default

The documentation for this class was generated from the following file: