Template Struct quantity

Struct Documentation

template<QuantitySpec U, Numeric Rep = f_t>
struct quantity

A quantity wraps an underlying numeric representation with static units.

Template Parameters:
  • U – the quantity spec, specifying units, dimensions and magnitude

  • Rep – the underlying numeric representations (defaults to the standard floating point f_t)

Public Types

using spec = U
using rep = Rep
using data_t = std::conditional_t<is_unitless_v<U>, Rep, au::Quantity<U, Rep>>

Public Functions

constexpr quantity() noexcept = default
inline constexpr quantity(zero_t) noexcept
inline constexpr quantity(const au::Quantity<U, Rep> &q) noexcept
inline constexpr quantity(const Rep &q) noexcept
template<QuantitySpecOf<U> U2, Numeric Rep2>
inline constexpr quantity(const quantity<U2, Rep2> &q) noexcept
constexpr quantity(const quantity&) noexcept = default
inline constexpr quantity &operator=(const quantity &o) noexcept
template<QuantitySpecOf<U> U2, Numeric Rep2>
inline constexpr bool operator==(const quantity<U2, Rep2> &o) const noexcept
template<QuantitySpecOf<U> U2, Numeric Rep2>
inline constexpr bool operator!=(const quantity<U2, Rep2> &o) const noexcept
template<QuantitySpecOf<U> U2, Numeric Rep2>
inline constexpr bool operator>=(const quantity<U2, Rep2> &o) const noexcept
template<QuantitySpecOf<U> U2, Numeric Rep2>
inline constexpr bool operator<=(const quantity<U2, Rep2> &o) const noexcept
template<QuantitySpecOf<U> U2, Numeric Rep2>
inline constexpr bool operator>(const quantity<U2, Rep2> &o) const noexcept
template<QuantitySpecOf<U> U2, Numeric Rep2>
inline constexpr bool operator<(const quantity<U2, Rep2> &o) const noexcept
inline constexpr const auto &operator+=(const quantity &o) noexcept
inline constexpr const auto &operator-=(const quantity &o) noexcept
inline constexpr const auto &operator*=(Rep r) noexcept
inline constexpr const auto &operator/=(Rep r) noexcept
inline constexpr auto operator+() const noexcept
inline constexpr auto operator-() const noexcept
inline constexpr auto in(wt::unit<u::unitless>) const noexcept

Returns the underlying representation in desired units.

inline constexpr auto in(auto u) const noexcept

Returns the underlying representation in desired units.

inline constexpr auto in_lossy(auto u) const noexcept

Returns the underlying representation in desired units. Permits lossy truncating conversions.

template<Unit U2>
inline constexpr auto as(U2 u) const noexcept

Converts to a quantity in the desired units.

template<Unit U2>
inline constexpr auto as_lossy(U2 u) const noexcept

Converts to a quantity in the desired units. Permits lossy truncating conversions.

template<QuantitySpec U2, Numeric Rep2>
inline explicit constexpr operator quantity<U2, Rep2>() const noexcept
template<Numeric S>
inline constexpr operator S() const noexcept

Lossless conversion of the unitless quantity to its underlying representation.

inline explicit constexpr operator Rep() const noexcept

Potentially lossy conversion of the dimensionless quantity to its underlying representation.

Public Members

data_t v

Public Static Functions

static inline constexpr quantity zero() noexcept
static inline constexpr quantity zero() noexcept

Public Static Attributes

static constexpr auto unit = wt::unit<spec>{}