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

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

#include <quanta/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> && detail::_lossless_conversion<Rep2, Precision2, rep, precision> && detail::_quantity_castable<delta<Rep2, Precision2>, delta>
constexpr delta (const delta< Rep2, Precision2 > &temp)
 Constructs from another delta with different representation or precision.
 
template<typename Rep2 , typename Precision2 >
requires (!detail::_lossless_conversion<Rep2, Precision2, rep, precision> || !std::convertible_to<const Rep2&, rep>) && detail::_quantity_castable<delta<Rep2, Precision2>, delta>
constexpr delta (const delta< Rep2, Precision2 > &d)
 Explicit constructor for lossy conversions.
 
 ~delta ()=default
 
delta & operator= (const delta &)=default
 
constexpr rep count () const
 Returns the tick count.
 
constexpr delta< typename std::common_type< rep >::type, precision > operator+ () const
 
constexpr delta< typename std::common_type< rep >::type, precision > operator- () const
 
constexpr delta & operator++ ()
 
constexpr delta operator++ (int)
 
constexpr delta & operator-- ()
 
constexpr delta operator-- (int)
 
constexpr delta & operator+= (const delta &d)
 
constexpr delta & operator-= (const delta &d)
 
constexpr delta & operator*= (const rep &r)
 
constexpr delta & operator/= (const rep &r)
 
constexpr delta & operator%= (const rep &r)
 
constexpr delta & operator%= (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 quanta::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 98 of file thermo.hpp.

Member Typedef Documentation

◆ precision

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

The precision as a std::ratio.

Definition at line 107 of file thermo.hpp.

◆ rep

template<typename Rep , typename Precision >
using quanta::thermo::delta< Rep, Precision >::rep = Rep

The representation type.

Definition at line 105 of file thermo.hpp.

Constructor & Destructor Documentation

◆ delta() [1/5]

◆ delta() [2/5]

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

◆ delta() [3/5]

template<typename Rep , typename Precision >
template<typename Rep2 >
requires std::convertible_to<const Rep2&, rep> && (treat_as_inexact_v<rep> || !treat_as_inexact_v<Rep2>)
constexpr quanta::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 124 of file thermo.hpp.

◆ delta() [4/5]

template<typename Rep , typename Precision >
template<typename Rep2 , typename Precision2 >
requires std::convertible_to<const Rep2&, rep> && detail::_lossless_conversion<Rep2, Precision2, rep, precision> && detail::_quantity_castable<delta<Rep2, Precision2>, delta>
constexpr quanta::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 (the target rep is floating-point, or the target precision evenly divides the source precision and the source rep is not floating-point) and the source rep converts implicitly to the target rep. Any other conversion that the cast can perform is explicit (see below).

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

Definition at line 144 of file thermo.hpp.

◆ delta() [5/5]

template<typename Rep , typename Precision >
template<typename Rep2 , typename Precision2 >
requires (!detail::_lossless_conversion<Rep2, Precision2, rep, precision> || !std::convertible_to<const Rep2&, rep>) && detail::_quantity_castable<delta<Rep2, Precision2>, delta>
constexpr quanta::thermo::delta< Rep, Precision >::delta ( const delta< Rep2, Precision2 > &  d)
inlineexplicitconstexpr

Explicit constructor for lossy conversions.

Every conversion that the cast can perform and that is not implicit (see above) is explicit: a lossy one (to a coarser precision, or from a floating-point rep to an integral one), or one to a rep that the source rep converts to only explicitly. The value is that of the domain's cast, truncated toward zero. The cast can perform the conversion when the conversion factor between the precisions fits in a std::ratio and the reps are integral or have a common type with intmax_t through which the count converts.

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

Definition at line 167 of file thermo.hpp.

◆ ~delta()

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

Member Function Documentation

◆ count()

◆ max()

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

Returns the maximum representable delta.

Definition at line 239 of file thermo.hpp.

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

◆ min()

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

Returns the minimum (most negative) representable delta.

Definition at line 236 of file thermo.hpp.

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

◆ operator%=() [1/2]

template<typename Rep , typename Precision >
constexpr delta & quanta::thermo::delta< Rep, Precision >::operator%= ( const delta< Rep, Precision > &  d)
inlineconstexpr

Definition at line 225 of file thermo.hpp.

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

◆ operator%=() [2/2]

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

Definition at line 218 of file thermo.hpp.

◆ operator*=()

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

Definition at line 208 of file thermo.hpp.

◆ operator+()

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

Definition at line 176 of file thermo.hpp.

◆ operator++() [1/2]

template<typename Rep , typename Precision >
constexpr delta & quanta::thermo::delta< Rep, Precision >::operator++ ( )
inlineconstexpr

Definition at line 184 of file thermo.hpp.

◆ operator++() [2/2]

template<typename Rep , typename Precision >
constexpr delta quanta::thermo::delta< Rep, Precision >::operator++ ( int  )
inlineconstexpr

Definition at line 189 of file thermo.hpp.

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

◆ operator+=()

template<typename Rep , typename Precision >
constexpr delta & quanta::thermo::delta< Rep, Precision >::operator+= ( const delta< Rep, Precision > &  d)
inlineconstexpr

Definition at line 198 of file thermo.hpp.

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

◆ operator-()

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

Definition at line 180 of file thermo.hpp.

◆ operator--() [1/2]

template<typename Rep , typename Precision >
constexpr delta & quanta::thermo::delta< Rep, Precision >::operator-- ( )
inlineconstexpr

Definition at line 191 of file thermo.hpp.

◆ operator--() [2/2]

template<typename Rep , typename Precision >
constexpr delta quanta::thermo::delta< Rep, Precision >::operator-- ( int  )
inlineconstexpr

Definition at line 196 of file thermo.hpp.

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

◆ operator-=()

template<typename Rep , typename Precision >
constexpr delta & quanta::thermo::delta< Rep, Precision >::operator-= ( const delta< Rep, Precision > &  d)
inlineconstexpr

Definition at line 203 of file thermo.hpp.

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

◆ operator/=()

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

Definition at line 213 of file thermo.hpp.

◆ operator=()

template<typename Rep , typename Precision >
delta & quanta::thermo::delta< Rep, Precision >::operator= ( const delta< Rep, Precision > &  )
default

◆ zero()

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

Returns a zero-length delta.

Definition at line 233 of file thermo.hpp.

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


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