quantity

quantity_math

namespace squint

Trigonometric functions

template<typename T>
auto sin(const T &x)

Sine function (only for dimensionless quantities or arithmetic types)

Template Parameters:

T – Quantitative (dimensionless) or arithmetic type

Parameters:

x – Input value

Returns:

Sine of x

template<typename T>
auto cos(const T &x)

Cosine function (only for dimensionless quantities or arithmetic types)

Template Parameters:

T – Quantitative (dimensionless) or arithmetic type

Parameters:

x – Input value

Returns:

Cosine of x

template<typename T>
auto tan(const T &x)

Tangent function (only for dimensionless quantities or arithmetic types)

Template Parameters:

T – Quantitative (dimensionless) or arithmetic type

Parameters:

x – Input value

Returns:

Tangent of x

Inverse trigonometric functions

template<typename T>
auto asin(const T &x)

Inverse sine function (only for dimensionless quantities or arithmetic types)

Template Parameters:

T – Quantitative (dimensionless) or arithmetic type

Parameters:

x – Input value

Returns:

Arcsine of x

template<typename T>
auto acos(const T &x)

Inverse cosine function (only for dimensionless quantities or arithmetic types)

Template Parameters:

T – Quantitative (dimensionless) or arithmetic type

Parameters:

x – Input value

Returns:

Arccosine of x

template<typename T>
auto atan(const T &x)

Inverse tangent function (only for dimensionless quantities or arithmetic types)

Template Parameters:

T – Quantitative (dimensionless) or arithmetic type

Parameters:

x – Input value

Returns:

Arctangent of x

template<typename T, typename U>
auto atan2(const T &y, const U &x)

Two-argument inverse tangent function.

Template Parameters:
  • T – Quantitative or arithmetic type for y

  • U – Quantitative or arithmetic type for x

Parameters:
  • y – Y-coordinate

  • x – X-coordinate

Returns:

Arctangent of y/x, using the signs of both arguments to determine the quadrant of the return value

Hyperbolic functions

template<typename T>
auto sinh(const T &x)

Hyperbolic sine function (only for dimensionless quantities or arithmetic types)

Template Parameters:

T – Quantitative (dimensionless) or arithmetic type

Parameters:

x – Input value

Returns:

Hyperbolic sine of x

template<typename T>
auto cosh(const T &x)

Hyperbolic cosine function (only for dimensionless quantities or arithmetic types)

Template Parameters:

T – Quantitative (dimensionless) or arithmetic type

Parameters:

x – Input value

Returns:

Hyperbolic cosine of x

template<typename T>
auto tanh(const T &x)

Hyperbolic tangent function (only for dimensionless quantities or arithmetic types)

Template Parameters:

T – Quantitative (dimensionless) or arithmetic type

Parameters:

x – Input value

Returns:

Hyperbolic tangent of x

Inverse hyperbolic functions

template<typename T>
auto asinh(const T &x)

Inverse hyperbolic sine function (only for dimensionless quantities or arithmetic types)

Template Parameters:

T – Quantitative (dimensionless) or arithmetic type

Parameters:

x – Input value

Returns:

Inverse hyperbolic sine of x

template<typename T>
auto acosh(const T &x)

Inverse hyperbolic cosine function (only for dimensionless quantities or arithmetic types)

Template Parameters:

T – Quantitative (dimensionless) or arithmetic type

Parameters:

x – Input value

Returns:

Inverse hyperbolic cosine of x

template<typename T>
auto atanh(const T &x)

Inverse hyperbolic tangent function (only for dimensionless quantities or arithmetic types)

Template Parameters:

T – Quantitative (dimensionless) or arithmetic type

Parameters:

x – Input value

Returns:

Inverse hyperbolic tangent of x

Functions

template<quantitative T, quantitative U>
auto approx_equal(const T &a, const U &b, const typename T::value_type &epsilon = typename T::value_type{DEFAULT_EPSILON}) -> bool

Approximately equal comparison for quantities.

Template Parameters:
  • T – First quantitative type

  • U – Second quantitative type

Parameters:
  • a – First quantity

  • b – Second quantity

  • epsilon – Tolerance for comparison

Returns:

true if quantities are approximately equal, false otherwise

template<quantitative T, arithmetic U>
auto approx_equal(const T &a, const U &b, const U &epsilon = U{DEFAULT_EPSILON}) -> bool

Approximately equal comparison for mixed types (quantitative and arithmetic)

Template Parameters:
  • T – Quantitative type

  • U – Arithmetic type

Parameters:
  • a – Quantity

  • b – Arithmetic value

  • epsilon – Tolerance for comparison

Returns:

true if values are approximately equal, false otherwise

template<arithmetic T, quantitative U>
auto approx_equal(const T &a, const U &b, const T &epsilon = T{DEFAULT_EPSILON}) -> bool

Approximately equal comparison for mixed types (arithmetic and quantitative)

Template Parameters:
  • T – Arithmetic type

  • U – Quantitative type

Parameters:
  • a – Arithmetic value

  • b – Quantity

  • epsilon – Tolerance for comparison

Returns:

true if values are approximately equal, false otherwise

template<typename T>
auto abs(const T &x) -> T

Absolute value function.

Template Parameters:

T – Quantitative or arithmetic type

Parameters:

x – Input value

Returns:

Absolute value of x

template<typename T>
auto sqrt(const T &x)

Square root function.

Template Parameters:

T – Quantitative or arithmetic type

Parameters:

x – Input value

Returns:

Square root of x

template<int N, typename T>
auto root(const T &x)

Nth root function.

Template Parameters:

T – Quantitative or arithmetic type

Parameters:

x – Input value

Returns:

Nth root of x

template<typename T>
auto exp(const T &x)

Exponential function (only for dimensionless quantities or arithmetic types)

Template Parameters:

T – Quantitative (dimensionless) or arithmetic type

Parameters:

x – Input value

Returns:

e raised to the power of x

template<typename T>
auto log(const T &x)

Natural logarithm function (only for dimensionless quantities or arithmetic types)

Template Parameters:

T – Quantitative (dimensionless) or arithmetic type

Parameters:

x – Input value

Returns:

Natural logarithm of x

template<int N, quantitative T>
auto pow(const T &x)

Power function for quantitative types.

Template Parameters:
  • N – Integer power

  • T – Quantitative type

Parameters:

x – Base value

Returns:

x raised to the power of N

quantity

Defines the quantity class for representing physical quantities with dimensions.

namespace squint
template<arithmetic T, dimensional D, error_checking E = error_checking::disabled>
class quantity
#include <squint/quantity/quantity.hpp>

Represents a physical quantity with a value and dimension.

Template Parameters:
  • T – The arithmetic type used to represent the value.

  • D – The dimension type representing the physical dimension.

  • E – The error checking policy.

Subclassed by squint::units::unit< T, D, Scale, Offset, ErrorChecking >

Constructors and Assignment

inline constexpr quantity() noexcept

Default constructor.

~quantity() = default

Destructor.

inline explicit constexpr quantity(const T &value) noexcept

Explicit constructor from value.

constexpr quantity(const quantity&) noexcept = default

Copy constructor.

constexpr quantity(quantity&&) noexcept = default

Move constructor.

constexpr auto operator=(const quantity&) noexcept -> quantity& = default

Copy assignment operator.

constexpr auto operator=(quantity&&) noexcept -> quantity& = default

Move assignment operator.

Conversion Constructors and Operators

template<arithmetic U>
inline constexpr quantity(const U &value) noexcept

Implicit conversion constructor for dimensionless quantities from arithmetic types.

Template Parameters:

U – Arithmetic type to convert from

template<typename U>
inline explicit operator U() const noexcept

Explicit conversion operator to other types.

Template Parameters:

U – Type to convert to

inline explicit constexpr operator T() const noexcept

Explicit conversion operator for non-dimensionless quantities.

inline constexpr operator T() const noexcept

Implicit conversion operator for dimensionless quantities.

template<typename U, error_checking OtherErrorChecking>
inline constexpr quantity(const quantity<U, D, OtherErrorChecking> &other) noexcept

Conversion constructor for quantities with different error checking.

Template Parameters:
  • U – Value type of the other quantity

  • OtherErrorChecking – Error checking policy of the other quantity

Accessors

inline constexpr auto value() noexcept -> T&
inline constexpr auto value() const noexcept -> const T&
template<quantitative Q>
inline constexpr auto as() const noexcept -> quantity<T, typename Q::dimension_type, E>

Arithmetic Operators

template<typename U>
inline constexpr auto operator*=(const U &scalar) -> quantity&
requires (arithmetic<U> || std::is_same_v<typename U::dimension_type, dimensions::unity>)

Multiply-assign operator.

Template Parameters:

U – Type of the scalar

Parameters:

scalar – Scalar to multiply by

Returns:

Reference to this quantity

template<typename U>
inline constexpr auto operator/=(const U &scalar) -> quantity&
requires (arithmetic<U> || std::is_same_v<typename U::dimension_type, dimensions::unity>)

Divide-assign operator.

Template Parameters:

U – Type of the scalar

Parameters:

scalar – Scalar to divide by

Returns:

Reference to this quantity

inline constexpr auto operator+=(const quantity &rhs) -> quantity&

Add-assign operator.

Parameters:

rhs – Quantity to add

Returns:

Reference to this quantity

inline constexpr auto operator-=(const quantity &rhs) -> quantity&

Subtract-assign operator.

Parameters:

rhs – Quantity to subtract

Returns:

Reference to this quantity

inline constexpr auto operator-() const noexcept -> quantity

Unary negation operator.

Returns:

Negated quantity

inline constexpr auto operator++() noexcept -> quantity&

Pre-increment operator.

Returns:

Reference to this quantity

inline constexpr auto operator++(int) noexcept -> quantity

Post-increment operator.

Returns:

Copy of the quantity before increment

inline constexpr auto operator--() noexcept -> quantity&

Pre-decrement operator.

Returns:

Reference to this quantity

inline constexpr auto operator--(int) noexcept -> quantity

Post-decrement operator.

Returns:

Copy of the quantity before decrement

Comparison Operators

inline constexpr auto operator<=>(const quantity &rhs) const noexcept

Three-way comparison operator.

Parameters:

rhs – Quantity to compare with

Returns:

Comparison result

inline constexpr auto operator==(const quantity &rhs) const noexcept -> bool

Equality comparison operator.

Parameters:

rhs – Quantity to compare with

Returns:

True if quantities are equal, false otherwise

Error Checking Methods

static inline constexpr auto error_checking() noexcept -> error_checking

Get the error checking policy.

template<typename U>
static inline constexpr void check_overflow_multiply(const T &a, const U &b)

Check for multiplication overflow.

Template Parameters:

U – Type of the second operand

Parameters:
  • a – First operand

  • b – Second operand

template<typename U>
static inline constexpr void check_division_by_zero(const U &b)

Check for division by zero.

Template Parameters:

U – Type of the divisor

Parameters:

b – Divisor

template<typename U>
static inline constexpr void check_underflow_divide(const T &a, const U &b)

Check for division underflow.

Template Parameters:

U – Type of the divisor

Parameters:
  • a – Dividend

  • b – Divisor

static inline constexpr void check_overflow_add(const T &a, const T &b)

Check for addition overflow.

Parameters:
  • a – First operand

  • b – Second operand

static inline constexpr void check_underflow_subtract(const T &a, const T &b)

Check for subtraction underflow.

Parameters:
  • a – First operand

  • b – Second operand

Public Types

using value_type = T
using dimension_type = D

Private Members

T value_

unit

namespace squint
namespace units

Functions

template<template<typename> class ToUnit, typename FromUnit>
constexpr auto convert_to(const FromUnit &q)

Generic conversion function between units.

Template Parameters:
  • ToUnit – The unit type to convert to (template template parameter).

  • FromUnit – The concrete unit type to convert from.

Parameters:

q – The quantity to convert.

Returns:

A new unit object of the target unit type.

template<typename T, typename D, T Scale = T(1), T Offset = T(0), error_checking ErrorChecking = error_checking::disabled>
struct unit : public squint::quantity<T, D, error_checking::disabled>
#include <squint/quantity/unit.hpp>

Base unit struct for all physical quantities.

Template Parameters:
  • T – The underlying numeric type (e.g., float, double).

  • D – The dimension of the unit.

  • Scale – The scale factor for conversion.

  • Offset – The offset for conversion.

  • ErrorChecking – The error checking policy.

Public Types

using base_quantity_type = quantity<T, D, ErrorChecking>

Public Functions

inline constexpr unit()
inline constexpr unit(const base_quantity_type &q)
template<typename U, U Scale2, U Offset2, error_checking OtherErrorChecking>
inline constexpr unit(const unit<U, D, Scale2, Offset2, OtherErrorChecking> &q)
template<typename U, typename D2, error_checking OtherErrorChecking>
unit(const quantity<U, D2, OtherErrorChecking> &q) = delete
template<typename U, typename D2, U Scale2, U Offset2, error_checking OtherErrorChecking>
unit(const unit<U, D2, Scale2, Offset2, OtherErrorChecking> &q) = delete
inline explicit constexpr unit(T unit_value)
inline constexpr auto unit_value() const -> T

Public Static Functions

static inline constexpr auto convert_to(const base_quantity_type &q) -> T
static inline constexpr auto convert_from(T value) -> base_quantity_type

Public Static Attributes

static constexpr T scale = Scale
static constexpr T offset = Offset

quantity_types

Defines type aliases for various quantity specializations.

This file provides convenient type aliases for quantities with different error checking policies and for constant quantities. It covers a wide range of physical quantities based on the dimensions defined in dimension_types.hpp.

namespace squint

Typedefs

template<typename T, dimensional D>
using checked_quantity_t = quantity<T, D, error_checking::enabled>

Type alias for quantities with error checking enabled.

Template Parameters:
  • T – The underlying arithmetic type of the quantity.

  • D – The dimension type of the quantity.

template<typename T, dimensional D>
using unchecked_quantity_t = quantity<T, D, error_checking::disabled>

Type alias for quantities with error checking disabled.

Template Parameters:
  • T – The underlying arithmetic type of the quantity.

  • D – The dimension type of the quantity.

template<floating_point T, typename Dimension>
using constant_quantity_t = unchecked_quantity_t<T, Dimension>

Template alias for constant quantities.

This alias creates an unchecked quantity with a floating-point type. It’s typically used for representing physical constants.

Template Parameters:
  • T – The underlying floating-point type of the quantity.

  • Dimension – The dimension type of the quantity.

template<typename T>
using pure_t = unchecked_quantity_t<T, dimensions::unity>

Base quantities corresponding to SI base units.

Type alias for a dimensionless quantity.

template<typename T>
using length_t = unchecked_quantity_t<T, dimensions::L>

Type alias for a length quantity.

template<typename T>
using duration_t = unchecked_quantity_t<T, dimensions::T>

Type alias for a duration quantity.

template<typename T>
using mass_t = unchecked_quantity_t<T, dimensions::M>

Type alias for a mass quantity.

template<typename T>
using temperature_t = unchecked_quantity_t<T, dimensions::K>

Type alias for a temperature quantity.

template<typename T>
using current_t = unchecked_quantity_t<T, dimensions::I>

Type alias for an electric current quantity.

template<typename T>
using amount_t = unchecked_quantity_t<T, dimensions::N>

Type alias for an amount of substance quantity.

template<typename T>
using luminous_intensity_t = unchecked_quantity_t<T, dimensions::J>

Type alias for a luminous intensity quantity.

template<typename T>
using velocity_t = unchecked_quantity_t<T, dimensions::velocity_dim>

Derived quantities based on SI base quantities.

Type alias for a velocity quantity.

template<typename T>
using acceleration_t = unchecked_quantity_t<T, dimensions::acceleration_dim>

Type alias for an acceleration quantity.

template<typename T>
using force_t = unchecked_quantity_t<T, dimensions::force_dim>

Type alias for a force quantity.

template<typename T>
using energy_t = unchecked_quantity_t<T, dimensions::energy_dim>

Type alias for an energy quantity.

template<typename T>
using power_t = unchecked_quantity_t<T, dimensions::power_dim>

Type alias for a power quantity.

template<typename T>
using pressure_t = unchecked_quantity_t<T, dimensions::pressure_dim>

Type alias for a pressure quantity.

template<typename T>
using charge_t = unchecked_quantity_t<T, dimensions::charge_dim>

Type alias for an electric charge quantity.

template<typename T>
using area_t = unchecked_quantity_t<T, dimensions::area_dim>

Type alias for an area quantity.

template<typename T>
using volume_t = unchecked_quantity_t<T, dimensions::volume_dim>

Type alias for a volume quantity.

template<typename T>
using density_t = unchecked_quantity_t<T, dimensions::density_dim>

Type alias for a density quantity.

template<typename T>
using frequency_t = unchecked_quantity_t<T, dimensions::frequency_dim>

Type alias for a frequency quantity.

template<typename T>
using angle_t = unchecked_quantity_t<T, dimensions::angle_dim>

Type alias for an angle quantity.

template<typename T>
using angular_velocity_t = unchecked_quantity_t<T, dimensions::angular_velocity_dim>

Type alias for an angular velocity quantity.

template<typename T>
using angular_acceleration_t = unchecked_quantity_t<T, dimensions::angular_acceleration_dim>

Type alias for an angular acceleration quantity.

template<typename T>
using torque_t = unchecked_quantity_t<T, dimensions::torque_dim>

Type alias for a torque quantity.

template<typename T>
using moment_of_inertia_t = unchecked_quantity_t<T, dimensions::moment_of_inertia_dim>

Type alias for a moment of inertia quantity.

template<typename T>
using momentum_t = unchecked_quantity_t<T, dimensions::momentum_dim>

Type alias for a linear momentum quantity.

template<typename T>
using angular_momentum_t = unchecked_quantity_t<T, dimensions::angular_momentum_dim>

Type alias for an angular momentum quantity.

template<typename T>
using voltage_t = unchecked_quantity_t<T, dimensions::voltage_dim>

Type alias for a voltage quantity.

template<typename T>
using resistance_t = unchecked_quantity_t<T, dimensions::resistance_dim>

Type alias for an electric resistance quantity.

template<typename T>
using conductance_t = unchecked_quantity_t<T, dimensions::conductance_dim>

Type alias for an electrical conductance quantity.

template<typename T>
using capacitance_t = unchecked_quantity_t<T, dimensions::capacitance_dim>

Type alias for a capacitance quantity.

template<typename T>
using magnetic_flux_t = unchecked_quantity_t<T, dimensions::magnetic_flux_dim>

Type alias for a magnetic flux quantity.

template<typename T>
using magnetic_flux_density_t = unchecked_quantity_t<T, dimensions::magnetic_flux_density_dim>

Type alias for a magnetic flux density quantity.

template<typename T>
using inductance_t = unchecked_quantity_t<T, dimensions::inductance_dim>

Type alias for an inductance quantity.

template<typename T>
using electric_field_strength_t = unchecked_quantity_t<T, dimensions::electric_field_strength_dim>

Type alias for an electric field strength quantity.

template<typename T>
using magnetic_field_strength_t = unchecked_quantity_t<T, dimensions::magnetic_field_strength_dim>

Type alias for a magnetic field strength quantity.

template<typename T>
using permittivity_t = unchecked_quantity_t<T, dimensions::permittivity_dim>

Type alias for a permittivity quantity.

template<typename T>
using permeability_t = unchecked_quantity_t<T, dimensions::permeability_dim>

Type alias for a permeability quantity.

template<typename T>
using specific_energy_t = unchecked_quantity_t<T, dimensions::specific_energy_dim>

Type alias for a specific energy quantity.

template<typename T>
using specific_heat_capacity_t = unchecked_quantity_t<T, dimensions::specific_heat_capacity_dim>

Type alias for a specific heat capacity quantity.

template<typename T>
using thermal_conductivity_t = unchecked_quantity_t<T, dimensions::thermal_conductivity_dim>

Type alias for a thermal conductivity quantity.

template<typename T>
using dynamic_viscosity_t = unchecked_quantity_t<T, dimensions::dynamic_viscosity_dim>

Type alias for a dynamic viscosity quantity.

template<typename T>
using kinematic_viscosity_t = unchecked_quantity_t<T, dimensions::kinematic_viscosity_dim>

Type alias for a kinematic viscosity quantity.

template<typename T>
using surface_tension_t = unchecked_quantity_t<T, dimensions::surface_tension_dim>

Type alias for a surface tension quantity.

template<typename T>
using strain_t = unchecked_quantity_t<T, dimensions::strain_dim>

Type alias for a strain quantity.

template<typename T>
using stress_t = unchecked_quantity_t<T, dimensions::stress_dim>

Type alias for a stress quantity.

template<typename T>
using youngs_modulus_t = unchecked_quantity_t<T, dimensions::youngs_modulus_dim>

Type alias for a Young’s modulus quantity.

template<typename T>
using poissons_ratio_t = unchecked_quantity_t<T, dimensions::poissons_ratio_dim>

Type alias for a Poisson’s ratio quantity.

template<typename T>
using bulk_modulus_t = unchecked_quantity_t<T, dimensions::bulk_modulus_dim>

Type alias for a bulk modulus quantity.

template<typename T>
using shear_modulus_t = unchecked_quantity_t<T, dimensions::shear_modulus_dim>

Type alias for a shear modulus quantity.

template<typename T>
using spring_constant_t = unchecked_quantity_t<T, dimensions::spring_constant_dim>

Type alias for a spring constant quantity.

template<typename T>
using damping_coefficient_t = unchecked_quantity_t<T, dimensions::damping_coefficient_dim>

Type alias for a damping coefficient quantity.

template<typename T>
using impulse_t = unchecked_quantity_t<T, dimensions::impulse_dim>

Type alias for an impulse quantity.

template<typename T>
using specific_impulse_t = unchecked_quantity_t<T, dimensions::specific_impulse_dim>

Type alias for a specific impulse quantity.

template<typename T>
using diffusivity_t = unchecked_quantity_t<T, dimensions::diffusivity_dim>

Type alias for a diffusivity quantity.

template<typename T>
using thermal_diffusivity_t = unchecked_quantity_t<T, dimensions::thermal_diffusivity_dim>

Type alias for a thermal diffusivity quantity.

template<typename T>
using heat_flux_t = unchecked_quantity_t<T, dimensions::heat_flux_dim>

Type alias for a heat flux quantity.

template<typename T>
using entropy_t = unchecked_quantity_t<T, dimensions::entropy_dim>

Type alias for an entropy quantity.

template<typename T>
using specific_entropy_t = unchecked_quantity_t<T, dimensions::specific_entropy_dim>

Type alias for a specific entropy quantity.

template<typename T>
using molar_entropy_t = unchecked_quantity_t<T, dimensions::molar_entropy_dim>

Type alias for a molar entropy quantity.

template<typename T>
using molar_mass_t = unchecked_quantity_t<T, dimensions::molar_mass_dim>

Type alias for a molar mass quantity.

template<typename T>
using luminous_flux_t = unchecked_quantity_t<T, dimensions::luminous_flux_dim>

Type alias for a luminous flux quantity.

template<typename T>
using illuminance_t = unchecked_quantity_t<T, dimensions::illuminance_dim>

Type alias for an illuminance quantity.

template<typename T>
using luminous_energy_t = unchecked_quantity_t<T, dimensions::luminous_energy_dim>

Type alias for a luminous energy quantity.

template<typename T>
using luminous_exposure_t = unchecked_quantity_t<T, dimensions::luminous_exposure_dim>

Type alias for a luminous exposure quantity.

template<typename T>
using radioactivity_t = unchecked_quantity_t<T, dimensions::radioactivity_dim>

Type alias for a radioactivity quantity.

template<typename T>
using absorbed_dose_t = unchecked_quantity_t<T, dimensions::absorbed_dose_dim>

Type alias for an absorbed dose quantity.

template<typename T>
using equivalent_dose_t = unchecked_quantity_t<T, dimensions::equivalent_dose_dim>

Type alias for an equivalent dose quantity.

template<typename T>
using catalytic_activity_t = unchecked_quantity_t<T, dimensions::catalytic_activity_dim>

Type alias for a catalytic activity quantity.

template<typename T>
using concentration_t = unchecked_quantity_t<T, dimensions::concentration_dim>

Type alias for a concentration quantity.

template<typename T>
using molality_t = unchecked_quantity_t<T, dimensions::molality_dim>

Type alias for a molality quantity.

template<typename T>
using flow_t = unchecked_quantity_t<T, dimensions::flow_dim>

Type alias for a flow quantity.

using pure = pure_t<float>

Base quantities with single precision floating-point types.

Type alias for a dimensionless quantity with a float type.

using length = length_t<float>

Type alias for a length quantity with a float type.

using duration = duration_t<float>

Type alias for a duration quantity with a float type.

using mass = mass_t<float>

Type alias for a mass quantity with a float type.

using temperature = temperature_t<float>

Type alias for a temperature quantity with a float type.

using current = current_t<float>

Type alias for an electric current quantity with a float type.

using amount = amount_t<float>

Type alias for an amount of substance quantity with a float type.

using luminous_intensity = luminous_intensity_t<float>

Type alias for a luminous intensity quantity with a float type.

using velocity = velocity_t<float>

Derived quantities with single precision floating-point types.

Type alias for a velocity quantity with a float type.

using acceleration = acceleration_t<float>

Type alias for an acceleration quantity with a float type.

using force = force_t<float>

Type alias for a force quantity with a float type.

using energy = energy_t<float>

Type alias for an energy quantity with a float type.

using power = power_t<float>

Type alias for a power quantity with a float type.

using pressure = pressure_t<float>

Type alias for a pressure quantity with a float type.

using charge = charge_t<float>

Type alias for an electric charge quantity with a float type.

using area = area_t<float>

Type alias for an area quantity with a float type.

using volume = volume_t<float>

Type alias for a volume quantity with a float type.

using density = density_t<float>

Type alias for a density quantity with a float type.

using frequency = frequency_t<float>

Type alias for a frequency quantity with a float type.

using angle = angle_t<float>

Type alias for an angle quantity with a float type.

using angular_velocity = angular_velocity_t<float>

Type alias for an angular velocity quantity with a float type.

using angular_acceleration = angular_acceleration_t<float>

Type alias for an angular acceleration quantity with a float type.

using torque = torque_t<float>

Type alias for a torque quantity with a float type.

using moment_of_inertia = moment_of_inertia_t<float>

Type alias for a moment of inertia quantity with a float type.

using momentum = momentum_t<float>

Type alias for a linear momentum quantity with a float type.

using angular_momentum = angular_momentum_t<float>

Type alias for an angular momentum quantity with a float type.

using voltage = voltage_t<float>

Type alias for a voltage quantity with a float type.

using resistance = resistance_t<float>

Type alias for an electric resistance quantity with a float type.

using conductance = conductance_t<float>

Type alias for an electrical conductance quantity with a float type.

using capacitance = capacitance_t<float>

Type alias for a capacitance quantity with a float type.

using magnetic_flux = magnetic_flux_t<float>

Type alias for a magnetic flux quantity with a float type.

using magnetic_flux_density = magnetic_flux_density_t<float>

Type alias for a magnetic flux density quantity with a float type.

using inductance = inductance_t<float>

Type alias for an inductance quantity with a float type.

using electric_field_strength = electric_field_strength_t<float>

Type alias for an electric field strength quantity with a float type.

using magnetic_field_strength = magnetic_field_strength_t<float>

Type alias for a magnetic field strength quantity with a float type.

using permittivity = permittivity_t<float>

Type alias for a permittivity quantity with a float type.

using permeability = permeability_t<float>

Type alias for a permeability quantity with a float type.

using specific_energy = specific_energy_t<float>

Type alias for a specific energy quantity with a float type.

using specific_heat_capacity = specific_heat_capacity_t<float>

Type alias for a specific heat capacity quantity with a float type.

using thermal_conductivity = thermal_conductivity_t<float>

Type alias for a thermal conductivity quantity with a float type.

using dynamic_viscosity = dynamic_viscosity_t<float>

Type alias for a dynamic viscosity quantity with a float type.

using kinematic_viscosity = kinematic_viscosity_t<float>

Type alias for a kinematic viscosity quantity with a float type.

using surface_tension = surface_tension_t<float>

Type alias for a surface tension quantity with a float type.

using strain = strain_t<float>

Type alias for a strain quantity with a float type.

using stress = stress_t<float>

Type alias for a stress quantity with a float type.

using youngs_modulus = youngs_modulus_t<float>

Type alias for a Young’s modulus quantity with a float type.

using poissons_ratio = poissons_ratio_t<float>

Type alias for a Poisson’s ratio quantity with a float type.

using bulk_modulus = bulk_modulus_t<float>

Type alias for a bulk modulus quantity with a float type.

using shear_modulus = shear_modulus_t<float>

Type alias for a shear modulus quantity with a float type.

using spring_constant = spring_constant_t<float>

Type alias for a spring constant quantity with a float type.

using damping_coefficient = damping_coefficient_t<float>

Type alias for a damping coefficient quantity with a float type.

using impulse = impulse_t<float>

Type alias for an impulse quantity with a float type.

using specific_impulse = specific_impulse_t<float>

Type alias for a specific impulse quantity with a float type.

using diffusivity = diffusivity_t<float>

Type alias for a diffusivity quantity with a float type.

using thermal_diffusivity = thermal_diffusivity_t<float>

Type alias for a thermal diffusivity quantity with a float type.

using heat_flux = heat_flux_t<float>

Type alias for a heat flux quantity with a float type.

using entropy = entropy_t<float>

Type alias for an entropy quantity with a float type.

using specific_entropy = specific_entropy_t<float>

Type alias for a specific entropy quantity with a float type.

using molar_entropy = molar_entropy_t<float>

Type alias for a molar entropy quantity with a float type.

using molar_mass = molar_mass_t<float>

Type alias for a molar mass quantity with a float type.

using luminous_flux = luminous_flux_t<float>

Type alias for a luminous flux quantity with a float type.

using illuminance = illuminance_t<float>

Type alias for an illuminance quantity with a float type.

using luminous_energy = luminous_energy_t<float>

Type alias for a luminous energy quantity with a float type.

using luminous_exposure = luminous_exposure_t<float>

Type alias for a luminous exposure quantity with a float type.

using radioactivity = radioactivity_t<float>

Type alias for a radioactivity quantity with a float type.

using absorbed_dose = absorbed_dose_t<float>

Type alias for an absorbed dose quantity with a float type.

using equivalent_dose = equivalent_dose_t<float>

Type alias for an equivalent dose quantity with a float type.

using catalytic_activity = catalytic_activity_t<float>

Type alias for a catalytic activity quantity with a float type.

using concentration = concentration_t<float>

Type alias for a concentration quantity with a float type.

using molality = molality_t<float>

Type alias for a molality quantity with a float type.

using flow = flow_t<float>

Type alias for a flow quantity with a float type.

dimension_types

Defines dimension types and operations for physical quantities.

This file provides a comprehensive set of dimension types used in physical calculations, It includes base dimensions (such as length, time, mass), derived dimensions (like velocity, energy), and utility types for dimension arithmetic. These types form the foundation for type-safe physical quantity calculations in the squint library.

namespace squint

Typedefs

template<dimensional U1, dimensional U2>
using dim_mult_t = typename dim_mult<U1, U2>::type

Utility types for performing arithmetic operations on dimensions.

Multiply two dimensions.

Template Parameters:
  • U1 – The first dimension.

  • U2 – The second dimension.

template<dimensional U1, dimensional U2>
using dim_div_t = typename dim_div<U1, U2>::type

Divide two dimensions.

Template Parameters:
  • U1 – The numerator dimension.

  • U2 – The denominator dimension.

template<dimensional U, std::integral auto const N>
using dim_pow_t = typename dim_pow<U, N>::type

Raise a dimension to an integer power.

Template Parameters:
  • U – The dimension to be raised.

  • N – The power to raise the dimension to.

template<dimensional U, std::integral auto const N>
using dim_root_t = typename dim_root<U, N>::type

Take the Nth root of a dimension.

Template Parameters:
  • U – The dimension to take the root of.

  • N – The root to take.

template<dimensional U>
using dim_inv_t = dim_div_t<dimension<std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>>, U>

Invert a dimension (raise to power -1).

Template Parameters:

U – The dimension to invert.

namespace dimensions

Namespace containing common dimension definitions.

This namespace provides a comprehensive set of dimension types used in physical calculations. It includes both base dimensions (corresponding to SI base units) and derived dimensions.

Typedefs

using unity = dimension<std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>>

Base dimensions corresponding to SI base units.

These dimensions form the foundation of the dimensional system and correspond to the seven SI base units.

Dimensionless quantity.

using L = dimension<std::ratio<1>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>>

Length dimension.

using T = dimension<std::ratio<0>, std::ratio<1>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>>

Time dimension.

using M = dimension<std::ratio<0>, std::ratio<0>, std::ratio<1>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>>

Mass dimension.

using K = dimension<std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>, std::ratio<0>, std::ratio<0>, std::ratio<0>>

Temperature dimension.

using I = dimension<std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>, std::ratio<0>, std::ratio<0>>

Electric current dimension.

using N = dimension<std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>, std::ratio<0>>

Amount of substance dimension.

using J = dimension<std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<0>, std::ratio<1>>

Luminous intensity dimension.

using velocity_dim = dim_div_t<L, T>

Derived dimensions based on SI base dimensions.

These dimensions are derived from the seven SI base dimensions.

Velocity dimension (length/time).

using acceleration_dim = dim_div_t<velocity_dim, T>

Acceleration dimension (velocity/time).

using force_dim = dim_mult_t<M, acceleration_dim>

Force dimension (mass * acceleration).

using energy_dim = dim_mult_t<force_dim, L>

Energy dimension (force * length).

using power_dim = dim_div_t<energy_dim, T>

Power dimension (energy/time).

using pressure_dim = dim_div_t<force_dim, dim_pow_t<L, 2>>

Pressure dimension (force/area).

using charge_dim = dim_mult_t<I, T>

Electric charge dimension (current * time).

using area_dim = dim_pow_t<L, 2>

Area dimension (length^2).

using volume_dim = dim_pow_t<L, 3>

Volume dimension (length^3).

using density_dim = dim_div_t<M, volume_dim>

Density dimension (mass/volume).

using frequency_dim = dim_inv_t<T>

Frequency dimension (1/time).

using angle_dim = unity

Angle dimension (dimensionless).

using angular_velocity_dim = dim_div_t<angle_dim, T>

Angular velocity dimension (angle/time).

using angular_acceleration_dim = dim_div_t<angular_velocity_dim, T>

Angular acceleration dimension (angular velocity/time).

using torque_dim = dim_mult_t<force_dim, L>

Torque dimension (force * length).

using moment_of_inertia_dim = dim_mult_t<M, area_dim>

Moment of inertia dimension (mass * area).

using momentum_dim = dim_mult_t<M, velocity_dim>

Momentum dimension (mass * velocity).

using angular_momentum_dim = dim_mult_t<moment_of_inertia_dim, angular_velocity_dim>

Angular momentum dimension (moment of inertia * angular velocity).

using voltage_dim = dim_div_t<power_dim, I>

Voltage dimension (power/current).

using resistance_dim = dim_div_t<voltage_dim, I>

Electric resistance dimension (voltage/current).

using conductance_dim = dim_inv_t<resistance_dim>

Electrical conductance dimension (1/resistance).

using capacitance_dim = dim_div_t<charge_dim, voltage_dim>

Capacitance dimension (charge/voltage).

using magnetic_flux_dim = dim_mult_t<voltage_dim, T>

Magnetic flux dimension (voltage * time).

using magnetic_flux_density_dim = dim_div_t<magnetic_flux_dim, area_dim>

Magnetic flux density dimension (magnetic flux / area).

using inductance_dim = dim_div_t<magnetic_flux_dim, I>

Inductance dimension (magnetic flux / current).

using electric_field_strength_dim = dim_div_t<voltage_dim, L>

Electric field strength dimension (voltage / length).

using magnetic_field_strength_dim = dim_div_t<I, L>

Magnetic field strength dimension (current / length).

using permittivity_dim = dim_div_t<capacitance_dim, L>

Permittivity dimension (capacitance / length).

using permeability_dim = dim_div_t<inductance_dim, L>

Permeability dimension (inductance / length).

using specific_energy_dim = dim_div_t<energy_dim, M>

Specific energy dimension (energy/mass).

using specific_heat_capacity_dim = dim_div_t<energy_dim, dim_mult_t<M, K>>

Specific heat capacity dimension (energy/(mass * temperature)).

using thermal_conductivity_dim = dim_div_t<power_dim, dim_mult_t<L, K>>

Thermal conductivity dimension (power/(length * temperature)).

using dynamic_viscosity_dim = dim_mult_t<pressure_dim, T>

Dynamic viscosity dimension (pressure * time).

using kinematic_viscosity_dim = dim_div_t<area_dim, T>

Kinematic viscosity dimension (area/time).

using surface_tension_dim = dim_div_t<force_dim, L>

Surface tension dimension (force/length).

using strain_dim = unity

Strain dimension (dimensionless).

using stress_dim = pressure_dim

Stress dimension (force/area).

using youngs_modulus_dim = stress_dim

Young’s modulus dimension (stress/strain).

using poissons_ratio_dim = unity

Poisson’s ratio dimension (dimensionless).

using bulk_modulus_dim = pressure_dim

Bulk modulus dimension (pressure).

using shear_modulus_dim = pressure_dim

Shear modulus dimension (pressure).

using spring_constant_dim = dim_div_t<force_dim, L>

Spring constant dimension (force/length).

using damping_coefficient_dim = dim_mult_t<force_dim, dim_div_t<T, L>>

Damping coefficient dimension (force * time / length).

using impulse_dim = dim_mult_t<force_dim, T>

Impulse dimension (force * time).

using specific_impulse_dim = dim_div_t<impulse_dim, M>

Specific impulse dimension (impulse/mass).

using diffusivity_dim = dim_div_t<area_dim, T>

Diffusivity dimension (area/time).

using thermal_diffusivity_dim = diffusivity_dim

Thermal diffusivity dimension (area/time).

using heat_flux_dim = dim_div_t<power_dim, area_dim>

Heat flux dimension (power/area).

using entropy_dim = dim_div_t<energy_dim, K>

Entropy dimension (energy/temperature).

using specific_entropy_dim = dim_div_t<entropy_dim, M>

Specific entropy dimension (entropy/mass).

using molar_entropy_dim = dim_div_t<entropy_dim, N>

Molar entropy dimension (entropy/amount of substance).

using molar_mass_dim = dim_div_t<M, N>

Molar mass dimension (mass/amount of substance).

using luminous_flux_dim = dim_mult_t<J, angle_dim>

Luminous flux dimension (luminous intensity * solid angle).

using illuminance_dim = dim_div_t<luminous_flux_dim, area_dim>

Illuminance dimension (luminous flux / area).

using luminous_energy_dim = dim_mult_t<luminous_flux_dim, T>

Luminous energy dimension (luminous flux * time).

using luminous_exposure_dim = dim_mult_t<illuminance_dim, T>

Luminous exposure dimension (illuminance * time).

using radioactivity_dim = frequency_dim

Radioactivity dimension (1/time).

using absorbed_dose_dim = specific_energy_dim

Absorbed dose dimension (energy/mass).

using equivalent_dose_dim = specific_energy_dim

Equivalent dose dimension (energy/mass).

using catalytic_activity_dim = dim_div_t<N, T>

Catalytic activity dimension (amount of substance / time).

using concentration_dim = dim_div_t<N, volume_dim>

Concentration dimension (amount of substance / volume).

using molality_dim = dim_div_t<N, M>

Molality dimension (amount of substance / mass).

using flow_dim = dim_div_t<volume_dim, T>

Flow dimension (volume / time).

unit_types

Defines unit types for various physical quantities.

This file provides a comprehensive set of unit types for physical quantities, including conversion factors between different units of the same quantity.

namespace squint
namespace units

Unnamed Group

template<typename T>
using meters_t = unit<T, dimensions::L>

Length units.

template<typename T>
using feet_t = unit<T, dimensions::L, static_cast<T>(FEET_TO_METERS)>
template<typename T>
using inches_t = unit<T, dimensions::L, static_cast<T>(INCHES_TO_METERS)>
template<typename T>
using kilometers_t = unit<T, dimensions::L, static_cast<T>(KILOMETERS_TO_METERS)>
template<typename T>
using miles_t = unit<T, dimensions::L, static_cast<T>(MILES_TO_METERS)>
template<typename T>
using nautical_miles_t = unit<T, dimensions::L, static_cast<T>(NAUTICAL_MILES_TO_METERS)>
template<typename T>
using light_years_t = unit<T, dimensions::L, static_cast<T>(LIGHT_YEARS_TO_METERS)>

Unnamed Group

template<typename T>
using seconds_t = unit<T, dimensions::T>

Time units.

template<typename T>
using minutes_t = unit<T, dimensions::T, static_cast<T>(MINUTES_TO_SECONDS)>
template<typename T>
using hours_t = unit<T, dimensions::T, static_cast<T>(HOURS_TO_SECONDS)>
template<typename T>
using days_t = unit<T, dimensions::T, static_cast<T>(DAYS_TO_SECONDS)>
template<typename T>
using years_t = unit<T, dimensions::T, static_cast<T>(YEARS_TO_SECONDS)>

Unnamed Group

template<typename T>
using kilograms_t = unit<T, dimensions::M>

Mass units.

template<typename T>
using grams_t = unit<T, dimensions::M, static_cast<T>(GRAMS_TO_KILOGRAMS)>
template<typename T>
using pounds_t = unit<T, dimensions::M, static_cast<T>(POUNDS_TO_KILOGRAMS)>
template<typename T>
using ounces_t = unit<T, dimensions::M, static_cast<T>(OUNCES_TO_KILOGRAMS)>
template<typename T>
using tonnes_t = unit<T, dimensions::M, static_cast<T>(TONNES_TO_KILOGRAMS)>

Unnamed Group

template<typename T>
using kelvin_t = unit<T, dimensions::K>

Temperature units.

template<typename T>
using celsius_t = unit<T, dimensions::K, T(1), static_cast<T>(CELSIUS_OFFSET)>
template<typename T>
using fahrenheit_t = unit<T, dimensions::K, static_cast<T>(FAHRENHEIT_SCALE), static_cast<T>(FAHRENHEIT_OFFSET)>

Unnamed Group

template<typename T>
using amperes_t = unit<T, dimensions::I>

Electric current units.

Unnamed Group

template<typename T>
using mole_t = unit<T, dimensions::N>

Amount of substance units.

Unnamed Group

template<typename T>
using candela_t = unit<T, dimensions::J>

Luminous intensity units.

Unnamed Group

template<typename T>
using radians_t = unit<T, dimensions::angle_dim>

Angle units.

template<typename T>
using degrees_t = unit<T, dimensions::angle_dim, static_cast<T>(DEGREES_TO_RADIANS)>
template<typename T>
using arcminutes_t = unit<T, dimensions::angle_dim, static_cast<T>(ARCMINUTES_TO_RADIANS)>
template<typename T>
using arcseconds_t = unit<T, dimensions::angle_dim, static_cast<T>(ARCSECONDS_TO_RADIANS)>

Unnamed Group

template<typename T>
using meters_per_second_t = unit<T, dimensions::velocity_dim>

Velocity units.

template<typename T>
using kilometers_per_hour_t = unit<T, dimensions::velocity_dim, static_cast<T>(1.0 / 3.6)>
template<typename T>
using miles_per_hour_t = unit<T, dimensions::velocity_dim, static_cast<T>(MILES_TO_METERS / 3600.0)>
template<typename T>
using feet_per_second_t = unit<T, dimensions::velocity_dim, static_cast<T>(FEET_TO_METERS)>
template<typename T>
using knots_t = unit<T, dimensions::velocity_dim, static_cast<T>(NAUTICAL_MILES_TO_METERS / 3600.0)>

Unnamed Group

template<typename T>
using meters_per_second_squared_t = unit<T, dimensions::acceleration_dim>

Acceleration units.

template<typename T>
using feet_per_second_squared_t = unit<T, dimensions::acceleration_dim, static_cast<T>(FEET_TO_METERS)>
template<typename T>
using standard_gravity_t = unit<T, dimensions::acceleration_dim, static_cast<T>(9.80665)>

Unnamed Group

template<typename T>
using newtons_t = unit<T, dimensions::force_dim>

Force units.

template<typename T>
using pounds_force_t = unit<T, dimensions::force_dim, static_cast<T>(POUNDS_TO_KILOGRAMS * 9.80665)>
template<typename T>
using dynes_t = unit<T, dimensions::force_dim, static_cast<T>(DYNE_TO_NEWTON)>

Unnamed Group

template<typename T>
using joules_t = unit<T, dimensions::energy_dim>

Energy units.

template<typename T>
using calories_t = unit<T, dimensions::energy_dim, static_cast<T>(CALORIES_TO_JOULES)>
template<typename T>
using kilocalories_t = unit<T, dimensions::energy_dim, static_cast<T>(1000.0 * CALORIES_TO_JOULES)>
template<typename T>
using btu_t = unit<T, dimensions::energy_dim, static_cast<T>(BTU_TO_JOULES)>
template<typename T>
using kilowatt_hours_t = unit<T, dimensions::energy_dim, static_cast<T>(KILOWATT_HOURS_TO_JOULES)>
template<typename T>
using electron_volts_t = unit<T, dimensions::energy_dim, static_cast<T>(ELECTRON_VOLTS_TO_JOULES)>
template<typename T>
using ergs_t = unit<T, dimensions::energy_dim, static_cast<T>(ERG_TO_JOULE)>

Unnamed Group

template<typename T>
using watts_t = unit<T, dimensions::power_dim>

Power units.

template<typename T>
using horsepower_t = unit<T, dimensions::power_dim, static_cast<T>(HORSEPOWER_TO_WATTS)>

Unnamed Group

template<typename T>
using pascals_t = unit<T, dimensions::pressure_dim>

Pressure units.

template<typename T>
using atmospheres_t = unit<T, dimensions::pressure_dim, static_cast<T>(ATMOSPHERES_TO_PASCALS)>
template<typename T>
using bars_t = unit<T, dimensions::pressure_dim, static_cast<T>(BAR_TO_PASCALS)>
template<typename T>
using millimeters_of_mercury_t = unit<T, dimensions::pressure_dim, static_cast<T>(MMHG_TO_PASCALS)>
template<typename T>
using pounds_per_square_inch_t = unit<T, dimensions::pressure_dim, static_cast<T>(PSI_TO_PASCALS)>

Unnamed Group

template<typename T>
using coulombs_t = unit<T, dimensions::charge_dim>

Electric charge units.

template<typename T>
using ampere_hours_t = unit<T, dimensions::charge_dim, static_cast<T>(3600.0)>
template<typename T>
using statcoulombs_t = unit<T, dimensions::charge_dim, static_cast<T>(STATCOULOMB_TO_COULOMB)>

Unnamed Group

template<typename T>
using volts_t = unit<T, dimensions::voltage_dim>

Electric potential units.

template<typename T>
using statvolts_t = unit<T, dimensions::voltage_dim, static_cast<T>(STATVOLT_TO_VOLT)>

Unnamed Group

template<typename T>
using farads_t = unit<T, dimensions::capacitance_dim>

Capacitance units.

template<typename T>
using statfarads_t = unit<T, dimensions::capacitance_dim, static_cast<T>(STATFARAD_TO_FARAD)>

Unnamed Group

template<typename T>
using ohms_t = unit<T, dimensions::resistance_dim>

Resistance units.

template<typename T>
using statohms_t = unit<T, dimensions::resistance_dim, static_cast<T>(STATOHM_TO_OHM)>

Unnamed Group

template<typename T>
using siemens_t = unit<T, dimensions::conductance_dim>

Conductance units.

Unnamed Group

template<typename T>
using webers_t = unit<T, dimensions::magnetic_flux_dim>

Magnetic flux units.

template<typename T>
using maxwells_t = unit<T, dimensions::magnetic_flux_dim, static_cast<T>(1e-8)>

Unnamed Group

template<typename T>
using teslas_t = unit<T, dimensions::magnetic_flux_density_dim>

Magnetic flux density units.

template<typename T>
using gauss_t = unit<T, dimensions::magnetic_flux_density_dim, static_cast<T>(GAUSS_TO_TESLA)>

Unnamed Group

template<typename T>
using henries_t = unit<T, dimensions::inductance_dim>

Inductance units.

template<typename T>
using stathenries_t = unit<T, dimensions::inductance_dim, static_cast<T>(STATHENRY_TO_HENRY)>

Unnamed Group

template<typename T>
using square_meters_t = unit<T, dimensions::area_dim>

Area units.

template<typename T>
using square_feet_t = unit<T, dimensions::area_dim, static_cast<T>(FEET_TO_METERS * FEET_TO_METERS)>
template<typename T>
using square_inches_t = unit<T, dimensions::area_dim, static_cast<T>(INCHES_TO_METERS * INCHES_TO_METERS)>
template<typename T>
using square_kilometers_t = unit<T, dimensions::area_dim, static_cast<T>(KILOMETERS_TO_METERS * KILOMETERS_TO_METERS)>
template<typename T>
using square_miles_t = unit<T, dimensions::area_dim, static_cast<T>(MILES_TO_METERS * MILES_TO_METERS)>
template<typename T>
using hectares_t = unit<T, dimensions::area_dim, static_cast<T>(10000.0)>
template<typename T>
using acres_t = unit<T, dimensions::area_dim, static_cast<T>(4046.8564224)>

Unnamed Group

template<typename T>
using cubic_meters_t = unit<T, dimensions::volume_dim>

Volume units.

template<typename T>
using liters_t = unit<T, dimensions::volume_dim, static_cast<T>(LITERS_TO_CUBIC_METERS)>
template<typename T>
using gallons_t = unit<T, dimensions::volume_dim, static_cast<T>(GALLONS_TO_CUBIC_METERS)>
template<typename T>
using cubic_feet_t = unit<T, dimensions::volume_dim, static_cast<T>(FEET_TO_METERS * FEET_TO_METERS * FEET_TO_METERS)>
template<typename T>
using cubic_inches_t = unit<T, dimensions::volume_dim, static_cast<T>(INCHES_TO_METERS * INCHES_TO_METERS * INCHES_TO_METERS)>

Unnamed Group

template<typename T>
using kilograms_per_cubic_meter_t = unit<T, dimensions::density_dim>

Density units.

template<typename T>
using grams_per_cubic_centimeter_t = unit<T, dimensions::density_dim, static_cast<T>(1000.0)>
template<typename T>
using pounds_per_cubic_foot_t = unit<T, dimensions::density_dim, static_cast<T>(POUNDS_TO_KILOGRAMS / (FEET_TO_METERS * FEET_TO_METERS * FEET_TO_METERS))>

Unnamed Group

template<typename T>
using hertz_t = unit<T, dimensions::frequency_dim>

Frequency units.

template<typename T>
using kilohertz_t = unit<T, dimensions::frequency_dim, static_cast<T>(1000.0)>
template<typename T>
using megahertz_t = unit<T, dimensions::frequency_dim, static_cast<T>(1e6)>
template<typename T>
using gigahertz_t = unit<T, dimensions::frequency_dim, static_cast<T>(1e9)>

Unnamed Group

template<typename T>
using radians_per_second_t = unit<T, dimensions::angular_velocity_dim>

Angular velocity units.

template<typename T>
using degrees_per_second_t = unit<T, dimensions::angular_velocity_dim, static_cast<T>(DEGREES_TO_RADIANS)>
template<typename T>
using revolutions_per_minute_t = unit<T, dimensions::angular_velocity_dim, static_cast<T>(2.0 * std::numbers::pi / 60.0)>

Unnamed Group

template<typename T>
using radians_per_second_squared_t = unit<T, dimensions::angular_acceleration_dim>

Angular acceleration units.

template<typename T>
using degrees_per_second_squared_t = unit<T, dimensions::angular_acceleration_dim, static_cast<T>(DEGREES_TO_RADIANS)>

Unnamed Group

template<typename T>
using newton_meters_t = unit<T, dimensions::torque_dim>

Torque units.

template<typename T>
using foot_pounds_t = unit<T, dimensions::torque_dim, static_cast<T>(FEET_TO_METERS * POUNDS_TO_KILOGRAMS * 9.80665)>

Unnamed Group

template<typename T>
using kilogram_square_meters_t = unit<T, dimensions::moment_of_inertia_dim>

Moment of inertia units.

Unnamed Group

template<typename T>
using pascal_seconds_t = unit<T, dimensions::dynamic_viscosity_dim>

Dynamic viscosity units.

template<typename T>
using poise_t = unit<T, dimensions::dynamic_viscosity_dim, static_cast<T>(POISE_TO_PASCAL_SECONDS)>

Unnamed Group

template<typename T>
using square_meters_per_second_t = unit<T, dimensions::kinematic_viscosity_dim>

Kinematic viscosity units.

template<typename T>
using stokes_t = unit<T, dimensions::kinematic_viscosity_dim, static_cast<T>(1e-4)>

Unnamed Group

template<typename T>
using newtons_per_meter_t = unit<T, dimensions::surface_tension_dim>

Surface tension units.

template<typename T>
using dynes_per_centimeter_t = unit<T, dimensions::surface_tension_dim, static_cast<T>(1e-3)>

Unnamed Group

template<typename T>
using joules_per_kilogram_kelvin_t = unit<T, dimensions::specific_heat_capacity_dim>

Specific heat capacity units.

template<typename T>
using calories_per_gram_celsius_t = unit<T, dimensions::specific_heat_capacity_dim, static_cast<T>(4184.0)>

Unnamed Group

template<typename T>
using watts_per_meter_kelvin_t = unit<T, dimensions::thermal_conductivity_dim>

Thermal conductivity units.

Unnamed Group

template<typename T>
using volts_per_meter_t = unit<T, dimensions::electric_field_strength_dim>

Electric field strength units.

Unnamed Group

template<typename T>
using farads_per_meter_t = unit<T, dimensions::permittivity_dim>

Permittivity units.

Unnamed Group

template<typename T>
using henries_per_meter_t = unit<T, dimensions::permeability_dim>

Permeability units.

Unnamed Group

template<typename T>
using grays_t = unit<T, dimensions::absorbed_dose_dim>

Absorbed dose units.

template<typename T>
using rads_t = unit<T, dimensions::absorbed_dose_dim, static_cast<T>(RAD_TO_GRAY)>

Unnamed Group

template<typename T>
using sieverts_t = unit<T, dimensions::equivalent_dose_dim>

Equivalent dose units.

template<typename T>
using rems_t = unit<T, dimensions::equivalent_dose_dim, static_cast<T>(REM_TO_SIEVERT)>

Unnamed Group

template<typename T>
using katal_t = unit<T, dimensions::catalytic_activity_dim>

Catalytic activity units.

template<typename T>
using enzyme_unit_t = unit<T, dimensions::catalytic_activity_dim, static_cast<T>(1.0 / 60.0)>

Unnamed Group

template<typename T>
using moles_per_cubic_meter_t = unit<T, dimensions::concentration_dim>

Concentration units.

template<typename T>
using moles_per_liter_t = unit<T, dimensions::concentration_dim, static_cast<T>(1000.0)>

Unnamed Group

template<typename T>
using moles_per_kilogram_t = unit<T, dimensions::molality_dim>

Molality units.

Unnamed Group

template<typename T>
using kilograms_per_mole_t = unit<T, dimensions::molar_mass_dim>

Molar mass units.

template<typename T>
using grams_per_mole_t = unit<T, dimensions::molar_mass_dim, static_cast<T>(0.001)>

Unnamed Group

template<typename T>
using lumens_t = unit<T, dimensions::luminous_flux_dim>

Luminous flux units.

Unnamed Group

template<typename T>
using lux_t = unit<T, dimensions::illuminance_dim>

Illuminance units.

template<typename T>
using foot_candles_t = unit<T, dimensions::illuminance_dim, static_cast<T>(10.7639)>

Unnamed Group

template<typename T>
using lumen_seconds_t = unit<T, dimensions::luminous_energy_dim>

Luminous energy units.

Unnamed Group

template<typename T>
using lux_seconds_t = unit<T, dimensions::luminous_exposure_dim>

Luminous exposure units.

Unnamed Group

template<typename T>
using becquerels_t = unit<T, dimensions::radioactivity_dim>

Radioactivity units.

template<typename T>
using curies_t = unit<T, dimensions::radioactivity_dim, static_cast<T>(CURIE_TO_BECQUEREL)>

Unnamed Group

template<typename T>
using cubic_meters_per_second_t = unit<T, dimensions::flow_dim>

Flow rate units.

template<typename T>
using liters_per_second_t = unit<T, dimensions::flow_dim, static_cast<T>(0.001)>
template<typename T>
using gallons_per_minute_t = unit<T, dimensions::flow_dim, static_cast<T>(GALLONS_TO_CUBIC_METERS / 60.0)>

Unnamed Group

using meters = meters_t<float>

Type aliases for length quantities with float type.

using feet = feet_t<float>
using inches = inches_t<float>
using kilometers = kilometers_t<float>
using miles = miles_t<float>
using nautical_miles = nautical_miles_t<float>
using light_years = light_years_t<float>

Unnamed Group

using seconds = seconds_t<float>

Type aliases for time quantities with float type.

using minutes = minutes_t<float>
using hours = hours_t<float>
using days = days_t<float>
using years = years_t<float>

Unnamed Group

using kilograms = kilograms_t<float>

Type aliases for mass quantities with float type.

using grams = grams_t<float>
using pounds = pounds_t<float>
using ounces = ounces_t<float>
using tonnes = tonnes_t<float>

Unnamed Group

using kelvin = kelvin_t<float>

Type aliases for temperature quantities with float type.

using celsius = celsius_t<float>
using fahrenheit = fahrenheit_t<float>

Unnamed Group

using amperes = amperes_t<float>

Type aliases for electric current quantities with float type.

Unnamed Group

using mole = mole_t<float>

Type aliases for amount of substance quantities with float type.

Unnamed Group

using candela = candela_t<float>

Type aliases for luminous intensity quantities with float type.

Unnamed Group

using radians = radians_t<float>

Type aliases for angle quantities with float type.

using degrees = degrees_t<float>
using arcminutes = arcminutes_t<float>
using arcseconds = arcseconds_t<float>

Unnamed Group

using meters_per_second = meters_per_second_t<float>

Type aliases for velocity quantities with float type.

using kilometers_per_hour = kilometers_per_hour_t<float>
using miles_per_hour = miles_per_hour_t<float>
using feet_per_second = feet_per_second_t<float>
using knots = knots_t<float>

Unnamed Group

using meters_per_second_squared = meters_per_second_squared_t<float>

Type aliases for acceleration quantities with float type.

using feet_per_second_squared = feet_per_second_squared_t<float>
using standard_gravity = standard_gravity_t<float>

Unnamed Group

using newtons = newtons_t<float>

Type aliases for force quantities with float type.

using pounds_force = pounds_force_t<float>
using dynes = dynes_t<float>

Unnamed Group

using joules = joules_t<float>

Type aliases for energy quantities with float type.

using calories = calories_t<float>
using kilocalories = kilocalories_t<float>
using btu = btu_t<float>
using kilowatt_hours = kilowatt_hours_t<float>
using electron_volts = electron_volts_t<float>
using ergs = ergs_t<float>

Unnamed Group

using watts = watts_t<float>

Type aliases for power quantities with float type.

using horsepower = horsepower_t<float>

Unnamed Group

using pascals = pascals_t<float>

Type aliases for pressure quantities with float type.

using atmospheres = atmospheres_t<float>
using bars = bars_t<float>
using millimeters_of_mercury = millimeters_of_mercury_t<float>
using pounds_per_square_inch = pounds_per_square_inch_t<float>

Unnamed Group

using coulombs = coulombs_t<float>

Type aliases for electric charge quantities with float type.

using ampere_hours = ampere_hours_t<float>
using statcoulombs = statcoulombs_t<float>

Unnamed Group

using volts = volts_t<float>

Type aliases for electric potential quantities with float type.

using statvolts = statvolts_t<float>

Unnamed Group

using farads = farads_t<float>

Type aliases for capacitance quantities with float type.

using statfarads = statfarads_t<float>

Unnamed Group

using ohms = ohms_t<float>

Type aliases for resistance quantities with float type.

using statohms = statohms_t<float>

Unnamed Group

using siemens = siemens_t<float>

Type aliases for conductance quantities with float type.

Unnamed Group

using webers = webers_t<float>

Type aliases for magnetic flux quantities with float type.

using maxwells = maxwells_t<float>

Unnamed Group

using teslas = teslas_t<float>

Type aliases for magnetic flux density quantities with float type.

using gauss = gauss_t<float>

Unnamed Group

using henries = henries_t<float>

Type aliases for inductance quantities with float type.

using stathenries = stathenries_t<float>

Unnamed Group

using square_meters = square_meters_t<float>

Type aliases for area quantities with float type.

using square_feet = square_feet_t<float>
using square_inches = square_inches_t<float>
using square_kilometers = square_kilometers_t<float>
using square_miles = square_miles_t<float>
using hectares = hectares_t<float>
using acres = acres_t<float>

Unnamed Group

using cubic_meters = cubic_meters_t<float>

Type aliases for volume quantities with float type.

using liters = liters_t<float>
using gallons = gallons_t<float>
using cubic_feet = cubic_feet_t<float>
using cubic_inches = cubic_inches_t<float>

Unnamed Group

using kilograms_per_cubic_meter = kilograms_per_cubic_meter_t<float>

Type aliases for density quantities with float type.

using grams_per_cubic_centimeter = grams_per_cubic_centimeter_t<float>
using pounds_per_cubic_foot = pounds_per_cubic_foot_t<float>

Unnamed Group

using hertz = hertz_t<float>

Type aliases for frequency quantities with float type.

using kilohertz = kilohertz_t<float>
using megahertz = megahertz_t<float>
using gigahertz = gigahertz_t<float>

Unnamed Group

using radians_per_second = radians_per_second_t<float>

Type aliases for angular velocity quantities with float type.

using degrees_per_second = degrees_per_second_t<float>
using revolutions_per_minute = revolutions_per_minute_t<float>

Unnamed Group

using radians_per_second_squared = radians_per_second_squared_t<float>

Type aliases for angular acceleration quantities with float type.

using degrees_per_second_squared = degrees_per_second_squared_t<float>

Unnamed Group

using newton_meters = newton_meters_t<float>

Type aliases for torque quantities with float type.

using foot_pounds = foot_pounds_t<float>

Unnamed Group

using kilogram_square_meters = kilogram_square_meters_t<float>

Type aliases for moment of inertia quantities with float type.

Unnamed Group

using pascal_seconds = pascal_seconds_t<float>

Type aliases for dynamic viscosity quantities with float type.

using poise = poise_t<float>

Unnamed Group

using square_meters_per_second = square_meters_per_second_t<float>

Type aliases for kinematic viscosity quantities with float type.

using stokes = stokes_t<float>

Unnamed Group

using newtons_per_meter = newtons_per_meter_t<float>

Type aliases for surface tension quantities with float type.

using dynes_per_centimeter = dynes_per_centimeter_t<float>

Unnamed Group

using joules_per_kilogram_kelvin = joules_per_kilogram_kelvin_t<float>

Type aliases for specific heat capacity quantities with float type.

using calories_per_gram_celsius = calories_per_gram_celsius_t<float>

Unnamed Group

using watts_per_meter_kelvin = watts_per_meter_kelvin_t<float>

Type aliases for thermal conductivity quantities with float type.

Unnamed Group

using volts_per_meter = volts_per_meter_t<float>

Type aliases for electric field strength quantities with float type.

Unnamed Group

using farads_per_meter = farads_per_meter_t<float>

Type aliases for permittivity quantities with float type.

Unnamed Group

using henries_per_meter = henries_per_meter_t<float>

Type aliases for permeability quantities with float type.

Unnamed Group

using grays = grays_t<float>

Type aliases for absorbed dose quantities with float type.

using rads = rads_t<float>

Unnamed Group

using sieverts = sieverts_t<float>

Type aliases for equivalent dose quantities with float type.

using rems = rems_t<float>

Unnamed Group

using katal = katal_t<float>

Type aliases for catalytic activity quantities with float type.

using enzyme_unit = enzyme_unit_t<float>

Unnamed Group

using moles_per_cubic_meter = moles_per_cubic_meter_t<float>

Type aliases for concentration quantities with float type.

using moles_per_liter = moles_per_liter_t<float>

Unnamed Group

using moles_per_kilogram = moles_per_kilogram_t<float>

Type aliases for molality quantities with float type.

Unnamed Group

using kilograms_per_mole = kilograms_per_mole_t<float>

Type aliases for molar mass quantities with float type.

using grams_per_mole = grams_per_mole_t<float>

Unnamed Group

using lumens = lumens_t<float>

Type aliases for luminous flux quantities with float type.

Unnamed Group

using lux = lux_t<float>

Type aliases for illuminance quantities with float type.

using foot_candles = foot_candles_t<float>

Unnamed Group

using lumen_seconds = lumen_seconds_t<float>

Type aliases for luminous energy quantities with float type.

Unnamed Group

using lux_seconds = lux_seconds_t<float>

Type aliases for luminous exposure quantities with float type.

Unnamed Group

using becquerels = becquerels_t<float>

Type aliases for radioactivity quantities with float type.

using curies = curies_t<float>

Unnamed Group

using cubic_meters_per_second = cubic_meters_per_second_t<float>

Type aliases for flow rate quantities with float type.

using liters_per_second = liters_per_second_t<float>
using gallons_per_minute = gallons_per_minute_t<float>

Unnamed Group

constexpr auto FEET_TO_METERS = 0.3048

Conversion constants for unit conversions.

constexpr auto INCHES_TO_METERS = 0.0254
constexpr auto KILOMETERS_TO_METERS = 1000.0
constexpr auto MILES_TO_METERS = 1609.344
constexpr auto NAUTICAL_MILES_TO_METERS = 1852.0
constexpr auto LIGHT_YEARS_TO_METERS = 9.4607304725808e15
constexpr auto MINUTES_TO_SECONDS = 60.0
constexpr auto HOURS_TO_SECONDS = 3600.0
constexpr auto DAYS_TO_SECONDS = 86400.0
constexpr auto YEARS_TO_SECONDS = 31557600.0
constexpr auto GRAMS_TO_KILOGRAMS = 0.001
constexpr auto POUNDS_TO_KILOGRAMS = 0.45359237
constexpr auto OUNCES_TO_KILOGRAMS = 0.028349523125
constexpr auto TONNES_TO_KILOGRAMS = 1000.0
constexpr auto CELSIUS_OFFSET = 273.15
constexpr auto FAHRENHEIT_SCALE = 5.0 / 9.0
constexpr auto FAHRENHEIT_OFFSET = 459.67
constexpr auto DEGREES_TO_RADIANS = std::numbers::pi / 180.0
constexpr auto ARCMINUTES_TO_RADIANS = DEGREES_TO_RADIANS / 60.0
constexpr auto ARCSECONDS_TO_RADIANS = DEGREES_TO_RADIANS / 3600.0
constexpr auto CALORIES_TO_JOULES = 4.184
constexpr auto BTU_TO_JOULES = 1055.06
constexpr auto KILOWATT_HOURS_TO_JOULES = 3.6e6
constexpr auto ELECTRON_VOLTS_TO_JOULES = 1.602176634e-19
constexpr auto HORSEPOWER_TO_WATTS = 745.7
constexpr auto ATMOSPHERES_TO_PASCALS = 101325.0
constexpr auto BAR_TO_PASCALS = 100000.0
constexpr auto MMHG_TO_PASCALS = 133.322
constexpr auto PSI_TO_PASCALS = 6894.75729
constexpr auto LITERS_TO_CUBIC_METERS = 0.001
constexpr auto GALLONS_TO_CUBIC_METERS = 0.00378541
constexpr auto POISE_TO_PASCAL_SECONDS = 0.1
constexpr auto GAUSS_TO_TESLA = 1e-4
constexpr auto STATCOULOMB_TO_COULOMB = 3.335641e-10
constexpr auto STATFARAD_TO_FARAD = 1.112650e-12
constexpr auto STATHENRY_TO_HENRY = 8.987552e11
constexpr auto STATOHM_TO_OHM = 8.987552e11
constexpr auto STATVOLT_TO_VOLT = 299.792458
constexpr auto DEBYE_TO_COULOMB_METER = 3.33564e-30
constexpr auto DYNE_TO_NEWTON = 1e-5
constexpr auto ERG_TO_JOULE = 1e-7
constexpr auto GILBERT_TO_AMPERE_TURN = 0.795774715459
constexpr auto STILB_TO_CANDELA_PER_SQUARE_METER = 1e4
constexpr auto PHOT_TO_LUX = 1e4
constexpr auto CURIE_TO_BECQUEREL = 3.7e10
constexpr auto ROENTGEN_TO_COULOMB_PER_KILOGRAM = 2.58e-4
constexpr auto RAD_TO_GRAY = 0.01
constexpr auto REM_TO_SIEVERT = 0.01

dimension

Defines operations for handling physical dimensions.

This file provides the core functionality for representing and manipulating physical dimensions in a type-safe manner. It uses the C++ standard library’s ratio type to represent dimensional exponents and defines operations for combining dimensions through multiplication, division, powers, and roots.

The dimensions are based on the seven SI base units: length, time, mass, temperature, electric current, amount of substance, and luminous intensity.

namespace squint
template<dimensional U1, dimensional U2>
struct dim_div
#include <squint/quantity/dimension.hpp>

Divides two dimensions.

This struct template provides a type alias for the result of dividing two dimensions. The exponents of each base dimension of the second dimension are subtracted from those of the first dimension.

Template Parameters:
  • U1 – The dividend dimension.

  • U2 – The divisor dimension.

Public Types

using type = dimension<std::ratio_subtract<typename U1::L, typename U2::L>, std::ratio_subtract<typename U1::T, typename U2::T>, std::ratio_subtract<typename U1::M, typename U2::M>, std::ratio_subtract<typename U1::K, typename U2::K>, std::ratio_subtract<typename U1::I, typename U2::I>, std::ratio_subtract<typename U1::N, typename U2::N>, std::ratio_subtract<typename U1::J, typename U2::J>>
template<dimensional U1, dimensional U2>
struct dim_mult
#include <squint/quantity/dimension.hpp>

Multiplies two dimensions.

This struct template provides a type alias for the result of multiplying two dimensions. The exponents of each base dimension are added.

Template Parameters:
  • U1 – The first dimension.

  • U2 – The second dimension.

Public Types

using type = dimension<std::ratio_add<typename U1::L, typename U2::L>, std::ratio_add<typename U1::T, typename U2::T>, std::ratio_add<typename U1::M, typename U2::M>, std::ratio_add<typename U1::K, typename U2::K>, std::ratio_add<typename U1::I, typename U2::I>, std::ratio_add<typename U1::N, typename U2::N>, std::ratio_add<typename U1::J, typename U2::J>>
template<dimensional U, std::integral auto const N>
struct dim_pow
#include <squint/quantity/dimension.hpp>

Raises a dimension to an integral power.

This struct template provides a type alias for the result of raising a dimension to an integral power. Each base dimension’s exponent is multiplied by the power.

Template Parameters:
  • U – The dimension to be raised to a power.

  • N – The integral power to raise the dimension to.

Public Types

using type = dimension<std::ratio_multiply<typename U::L, std::ratio<static_cast<std::intmax_t>(N)>>, std::ratio_multiply<typename U::T, std::ratio<static_cast<std::intmax_t>(N)>>, std::ratio_multiply<typename U::M, std::ratio<static_cast<std::intmax_t>(N)>>, std::ratio_multiply<typename U::K, std::ratio<static_cast<std::intmax_t>(N)>>, std::ratio_multiply<typename U::I, std::ratio<static_cast<std::intmax_t>(N)>>, std::ratio_multiply<typename U::N, std::ratio<static_cast<std::intmax_t>(N)>>, std::ratio_multiply<typename U::J, std::ratio<static_cast<std::intmax_t>(N)>>>
template<dimensional U, std::integral auto const N>
struct dim_root
#include <squint/quantity/dimension.hpp>

Takes the root of a dimension.

This struct template provides a type alias for the result of taking the Nth root of a dimension. Each base dimension’s exponent is divided by N.

Template Parameters:
  • U – The dimension to take the root of.

  • N – The root to take (must be positive).

Public Types

using type = dimension<std::ratio_divide<typename U::L, std::ratio<static_cast<std::intmax_t>(N)>>, std::ratio_divide<typename U::T, std::ratio<static_cast<std::intmax_t>(N)>>, std::ratio_divide<typename U::M, std::ratio<static_cast<std::intmax_t>(N)>>, std::ratio_divide<typename U::K, std::ratio<static_cast<std::intmax_t>(N)>>, std::ratio_divide<typename U::I, std::ratio<static_cast<std::intmax_t>(N)>>, std::ratio_divide<typename U::N, std::ratio<static_cast<std::intmax_t>(N)>>, std::ratio_divide<typename U::J, std::ratio<static_cast<std::intmax_t>(N)>>>
template<rational Length, rational Time, rational Mass, rational Temp, rational Current, rational AmountOfSubstance, rational LuminousIntensity>
struct dimension
#include <squint/quantity/dimension.hpp>

Represents a physical dimension.

This struct template represents a physical dimension as a combination of rational exponents for each of the seven SI base dimensions.

Template Parameters:
  • Length – Exponent for length dimension.

  • Time – Exponent for time dimension.

  • Mass – Exponent for mass dimension.

  • Temp – Exponent for temperature dimension.

  • Current – Exponent for electric current dimension.

  • AmountOfSubstance – Exponent for amount of substance dimension.

  • LuminousIntensity – Exponent for luminous intensity dimension.

Public Types

using L = Length
using T = Time
using M = Mass
using K = Temp
using I = Current
using N = AmountOfSubstance
using J = LuminousIntensity

quantity_ops

Defines arithmetic and stream operations for quantitative types.

This file provides operator overloads for arithmetic operations between quantitative types (such as quantities and units), between quantitative types and scalars, and for stream I/O operations. It uses concepts to ensure type safety and proper dimension handling in calculations.

Note

All operations return quantity types, even when operating on unit types, to ensure consistent behavior and dimension tracking.

namespace squint

Functions

template<quantitative T1, quantitative T2>
constexpr auto operator+(const T1 &lhs, const T2 &rhs)

Addition operator for quantitative types.

Note

Both operands must have the same dimension.

Template Parameters:
  • T1 – The type of the left-hand operand.

  • T2 – The type of the right-hand operand.

Parameters:
  • lhs – The left-hand side quantitative value.

  • rhs – The right-hand side quantitative value.

Throws:

std::overflow_error – if error checking is enabled and addition would cause overflow.

Returns:

A new quantity representing the sum.

template<quantitative T1, quantitative T2>
constexpr auto operator-(const T1 &lhs, const T2 &rhs)

Subtraction operator for quantitative types.

Note

Both operands must have the same dimension.

Template Parameters:
  • T1 – The type of the left-hand operand.

  • T2 – The type of the right-hand operand.

Parameters:
  • lhs – The left-hand side quantitative value.

  • rhs – The right-hand side quantitative value.

Throws:

std::underflow_error – if error checking is enabled and subtraction would cause underflow.

Returns:

A new quantity representing the difference.

template<quantitative T1, quantitative T2>
constexpr auto operator*(const T1 &lhs, const T2 &rhs)

Multiplication operator for quantitative types.

Note

The resulting dimension is the product of the operands’ dimensions.

Template Parameters:
  • T1 – The type of the left-hand operand.

  • T2 – The type of the right-hand operand.

Parameters:
  • lhs – The left-hand side quantitative value.

  • rhs – The right-hand side quantitative value.

Throws:

std::overflow_error – if error checking is enabled and multiplication would cause overflow.

Returns:

A new quantity representing the product.

template<quantitative T1, quantitative T2>
constexpr auto operator/(const T1 &lhs, const T2 &rhs)

Division operator for quantitative types.

Note

The resulting dimension is the quotient of the operands’ dimensions.

Template Parameters:
  • T1 – The type of the left-hand operand.

  • T2 – The type of the right-hand operand.

Parameters:
  • lhs – The left-hand side quantitative value.

  • rhs – The right-hand side quantitative value.

Throws:
  • std::domain_error – if error checking is enabled and the divisor is zero.

  • std::underflow_error – if error checking is enabled and division would cause underflow.

Returns:

A new quantity representing the quotient.

template<arithmetic T, quantitative U>
constexpr auto operator*(const T &scalar, const U &q)

Multiplication operator for scalar and quantitative type.

Multiplication operator for quantitative type and scalar.

Note

This operator delegates to the scalar-first multiplication operator.

Template Parameters:
  • T – The scalar type.

  • U – The quantitative type.

  • T – The quantitative type.

  • U – The scalar type.

Parameters:
  • scalar – The scalar value.

  • q – The quantitative value.

  • q – The quantitative value.

  • scalar – The scalar value.

Throws:

std::overflow_error – if error checking is enabled and multiplication would cause overflow.

Returns:

A new quantity representing the product.

Returns:

A new quantity representing the product.

template<quantitative T, arithmetic U>
constexpr auto operator/(const T &q, const U &scalar)

Division operator for quantitative type and scalar.

Division operator for scalar and quantitative type.

Note

The resulting dimension is the inverse of the quantitative type’s dimension.

Template Parameters:
  • T – The quantitative type.

  • U – The scalar type.

  • T – The scalar type.

  • U – The quantitative type.

Parameters:
  • q – The quantitative value.

  • scalar – The scalar value.

  • scalar – The scalar value.

  • q – The quantitative value.

Throws:
  • std::domain_error – if error checking is enabled and the scalar is zero.

  • std::underflow_error – if error checking is enabled and division would cause underflow.

  • std::domain_error – if error checking is enabled and the quantitative value is zero.

  • std::underflow_error – if error checking is enabled and division would cause underflow.

Returns:

A new quantity representing the quotient.

Returns:

A new quantity representing the quotient.

template<quantitative T>
auto operator<<(std::ostream &os, const T &q) -> std::ostream&

Output stream operator for quantitative types.

Template Parameters:

T – The quantitative type.

Parameters:
  • os – The output stream.

  • q – The quantitative value to output.

Returns:

The output stream.

template<quantitative T>
auto operator>>(std::istream &is, T &q) -> std::istream&

Input stream operator for quantitative types.

Template Parameters:

T – The quantitative type.

Parameters:
  • is – The input stream.

  • q – The quantitative value to input into.

Throws:

Any – exception thrown by the quantitative type’s constructor if error checking is enabled.

Returns:

The input stream.

constants

Defines physical and mathematical constants as dimensioned quantities.

This file provides a set of commonly used constants in physics and mathematics, represented as dimensioned quantities. The constants are organized into different categories: mathematical, SI (Système International), astronomical, and atomic/nuclear.

All constants are defined as static constexpr members of their respective structs, parameterized by a floating-point type T for flexibility in precision.

namespace squint
template<floating_point T>
struct astro_constants
#include <squint/quantity/constants.hpp>

Astronomical constants.

Provides commonly used astronomical constants as dimensioned quantities.

Template Parameters:

T – The underlying floating-point type for the constants.

Public Static Attributes

static constexpr auto AU = constant_quantity_t<T, dimensions::L>(T(1.495978707e11))

Astronomical Unit (m).

static constexpr auto parsec = constant_quantity_t<T, dimensions::L>(T(3.0856775814913673e16))

Parsec (m).

static constexpr auto light_year = si_constants<T>::c * constant_quantity_t<T, dimensions::T>(T(365.25) * T(24) * T(3600))

Light year (m).

static constexpr auto solar_mass = constant_quantity_t<T, dimensions::M>(T(1.988847e30))

Solar mass (kg).

static constexpr auto earth_mass = constant_quantity_t<T, dimensions::M>(T(5.97217e24))

Earth mass (kg).

static constexpr auto earth_radius = constant_quantity_t<T, dimensions::L>(T(6.3781e6))

Earth radius (equatorial) (m).

static constexpr auto g = constant_quantity_t<T, dimensions::acceleration_dim>(T(9.80665))

Standard gravitational acceleration on Earth (m/s²).

template<floating_point T>
struct atomic_constants
#include <squint/quantity/constants.hpp>

Atomic and nuclear constants.

Provides constants related to atomic and nuclear physics as dimensioned quantities.

Template Parameters:

T – The underlying floating-point type for the constants.

Public Static Attributes

static constexpr auto R_inf = constant_quantity_t<T, dimensions::frequency_dim>(T(10973731.568160))

Rydberg constant (m^-1).

static constexpr auto a_0 = constant_quantity_t<T, dimensions::L>(T(5.29177210903e-11))

Bohr radius (m).

static constexpr auto r_e = constant_quantity_t<T, dimensions::L>(T(2.8179403262e-15))

Classical electron radius (m).

static constexpr auto m_p_m_e = si_constants<T>::m_p / si_constants<T>::m_e

Proton-electron mass ratio (dimensionless).

template<floating_point T>
struct math_constants
#include <squint/quantity/constants.hpp>

Mathematical constants.

Provides fundamental mathematical constants as dimensionless quantities.

Template Parameters:

T – The underlying floating-point type for the constants.

Public Static Attributes

static constexpr auto pi = constant_quantity_t<T, dimensions::unity>(std::numbers::pi_v<T>)

The ratio of a circle’s circumference to its diameter.

static constexpr auto e = constant_quantity_t<T, dimensions::unity>(std::numbers::e_v<T>)

The base of natural logarithms.

static constexpr auto sqrt2 = constant_quantity_t<T, dimensions::unity>(std::numbers::sqrt2_v<T>)

The square root of 2.

static constexpr auto ln2 = constant_quantity_t<T, dimensions::unity>(std::numbers::ln2_v<T>)

The natural logarithm of 2.

static constexpr auto phi = constant_quantity_t<T, dimensions::unity>(std::numbers::phi_v<T>)

The golden ratio.

template<floating_point T>
struct si_constants
#include <squint/quantity/constants.hpp>

Physical constants in the SI system.

Provides fundamental physical constants as dimensioned quantities in the SI system.

Template Parameters:

T – The underlying floating-point type for the constants.

Public Static Attributes

static constexpr auto c = constant_quantity_t<T, dimensions::velocity_dim>(T(299'792'458.0))

Speed of light in vacuum (m/s).

static constexpr auto h = constant_quantity_t<T, dim_mult_t<dimensions::energy_dim, dimensions::T>>(T(6.62607015e-34))

Planck constant (J⋅s).

static constexpr auto hbar = h / (T(2) * math_constants<T>::pi)

Reduced Planck constant (J⋅s).

static constexpr auto G = constant_quantity_t<T, dim_div_t<dim_mult_t<dimensions::force_dim, dimensions::area_dim>, dim_pow_t<dimensions::M, 2>>>(T(6.67430e-11))

Gravitational constant (m³/(kg⋅s²)).

static constexpr auto e_charge = constant_quantity_t<T, dimensions::charge_dim>(T(1.602176634e-19))

Elementary charge (C).

static constexpr auto m_e = constant_quantity_t<T, dimensions::M>(T(9.1093837015e-31))

Electron mass (kg).

static constexpr auto m_p = constant_quantity_t<T, dimensions::M>(T(1.67262192369e-27))

Proton mass (kg).

static constexpr auto alpha = constant_quantity_t<T, dimensions::unity>(T(7.2973525693e-3))

Fine-structure constant (dimensionless).

static constexpr auto k_B = constant_quantity_t<T, dim_div_t<dimensions::energy_dim, dimensions::K>>(T(1.380649e-23))

Boltzmann constant (J/K).

static constexpr auto N_A = constant_quantity_t<T, dim_inv_t<dimensions::N>>(T(6.02214076e23))

Avogadro constant (mol^-1).

static constexpr auto R = k_B * N_A

Gas constant (J/(mol⋅K)).

static constexpr auto epsilon_0 = constant_quantity_t<T, dim_div_t<dimensions::capacitance_dim, dimensions::L>>(T(8.8541878128e-12))

Vacuum electric permittivity (F/m).

static constexpr auto mu_0 = constant_quantity_t<T, dim_div_t<dimensions::inductance_dim, dimensions::L>>(T(1.25663706212e-6))

Vacuum magnetic permeability (H/m).

static constexpr auto sigma = constant_quantity_t<T, dim_div_t<dimensions::power_dim, dim_mult_t<dimensions::area_dim, dim_pow_t<dimensions::K, 4>>>>(T(5.670374419e-8))

Stefan-Boltzmann constant (W/(m²⋅K⁴)).