thermo 1.0.0
Type-safe temperature handling library modeled after std::chrono
Loading...
Searching...
No Matches
thermo::delta< Rep, Precision > Class Template Reference

A temperature difference with a representation and precision. More...

#include <thermo/thermo.hpp>

Public Types

using rep = Rep
 The representation type.
 
using precision = typename Precision::type
 The precision as a std::ratio.
 

Public Member Functions

constexpr delta ()=default
 Constructs a zero delta.
 
 delta (const delta &)=default
 
template<typename Rep2 >
requires std::convertible_to<const Rep2&, rep> && (treat_as_inexact_v<rep> || !treat_as_inexact_v<Rep2>)
constexpr delta (const Rep2 &r)
 Constructs from a tick count.
 
template<typename Rep2 , typename Precision2 >
requires std::convertible_to<const Rep2&, rep> && (treat_as_inexact_v<rep> || (_harmonic_precision<Precision2, precision> && !treat_as_inexact_v<Rep2>))
constexpr delta (const delta< Rep2, Precision2 > &temp)
 Constructs from another delta with different representation or precision.
 
 ~delta ()=default
 
deltaoperator= (const delta &)=default
 
constexpr rep count () const
 Returns the tick count.
 
constexpr delta< typename std::common_type< rep >::type, precisionoperator+ () const
 
constexpr delta< typename std::common_type< rep >::type, precisionoperator- () const
 
constexpr deltaoperator++ ()
 
constexpr delta operator++ (int)
 
constexpr deltaoperator-- ()
 
constexpr delta operator-- (int)
 
constexpr deltaoperator+= (const delta &d)
 
constexpr deltaoperator-= (const delta &d)
 
constexpr deltaoperator*= (const rep &r)
 
constexpr deltaoperator/= (const rep &r)
 
constexpr deltaoperator%= (const rep &r)
 
constexpr deltaoperator%= (const delta &d)
 

Static Public Member Functions

static constexpr delta zero () noexcept
 Returns a zero-length delta.
 
static constexpr delta min () noexcept
 Returns the minimum (most negative) representable delta.
 
static constexpr delta max () noexcept
 Returns the maximum representable delta.
 

Detailed Description

template<typename Rep, typename Precision>
class thermo::delta< Rep, Precision >

A temperature difference with a representation and precision.

Similar to std::chrono::duration, delta represents the difference between two temperatures. The precision is expressed as a std::ratio of one base unit (Kelvin or Celsius degree).

Template Parameters
RepArithmetic type for the tick count.
PrecisionA std::ratio representing the precision (default: 1).

Definition at line 120 of file thermo.hpp.

Member Typedef Documentation

◆ precision

using thermo::delta< Rep, Precision >::precision = typename Precision::type

The precision as a std::ratio.

Definition at line 129 of file thermo.hpp.

◆ rep

The representation type.

Definition at line 127 of file thermo.hpp.

Constructor & Destructor Documentation

◆ delta() [1/4]

◆ delta() [2/4]

thermo::delta< Rep, Precision >::delta ( const delta< Rep, Precision > &  )
default

◆ delta() [3/4]

template<typename Rep2 >
requires std::convertible_to<const Rep2&, rep> && (treat_as_inexact_v<rep> || !treat_as_inexact_v<Rep2>)
constexpr thermo::delta< Rep, Precision >::delta ( const Rep2 r)
inlineexplicitconstexpr

Constructs from a tick count.

Implicit for inexact types, explicit otherwise to prevent accidental precision loss.

Template Parameters
Rep2The source representation type.
Parameters
rThe tick count.

Definition at line 146 of file thermo.hpp.

◆ delta() [4/4]

constexpr thermo::delta< Rep, Precision >::delta ( const delta< Rep2, Precision2 > &  temp)
inlineconstexpr

Constructs from another delta with different representation or precision.

Implicit when the conversion is lossless (target precision evenly divides source precision). Explicit otherwise.

Template Parameters
Rep2Source representation type.
Precision2Source precision.
Parameters
tempThe source delta.

Definition at line 162 of file thermo.hpp.

◆ ~delta()

thermo::delta< Rep, Precision >::~delta ( )
default

Member Function Documentation

◆ count()

◆ max()

static constexpr delta thermo::delta< Rep, Precision >::max ( )
inlinestaticconstexprnoexcept

Returns the maximum representable delta.

Definition at line 234 of file thermo.hpp.

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

◆ min()

static constexpr delta thermo::delta< Rep, Precision >::min ( )
inlinestaticconstexprnoexcept

Returns the minimum (most negative) representable delta.

Definition at line 231 of file thermo.hpp.

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

◆ operator%=() [1/2]

Definition at line 220 of file thermo.hpp.

◆ operator%=() [2/2]

constexpr delta & thermo::delta< Rep, Precision >::operator%= ( const rep r)
inlineconstexpr

Definition at line 213 of file thermo.hpp.

◆ operator*=()

constexpr delta & thermo::delta< Rep, Precision >::operator*= ( const rep r)
inlineconstexpr

Definition at line 203 of file thermo.hpp.

◆ operator+()

constexpr delta< typename std::common_type< rep >::type, precision > thermo::delta< Rep, Precision >::operator+ ( ) const
inlineconstexpr

Definition at line 171 of file thermo.hpp.

◆ operator++() [1/2]

Definition at line 179 of file thermo.hpp.

◆ operator++() [2/2]

Definition at line 184 of file thermo.hpp.

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

◆ operator+=()

Definition at line 193 of file thermo.hpp.

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

◆ operator-()

constexpr delta< typename std::common_type< rep >::type, precision > thermo::delta< Rep, Precision >::operator- ( ) const
inlineconstexpr

Definition at line 175 of file thermo.hpp.

◆ operator--() [1/2]

Definition at line 186 of file thermo.hpp.

◆ operator--() [2/2]

Definition at line 191 of file thermo.hpp.

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

◆ operator-=()

Definition at line 198 of file thermo.hpp.

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

◆ operator/=()

constexpr delta & thermo::delta< Rep, Precision >::operator/= ( const rep r)
inlineconstexpr

Definition at line 208 of file thermo.hpp.

◆ operator=()

◆ zero()

static constexpr delta thermo::delta< Rep, Precision >::zero ( )
inlinestaticconstexprnoexcept

Returns a zero-length delta.

Definition at line 228 of file thermo.hpp.

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


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