20#include <system_error>
107template<
typename Unit,
typename Rep,
typename Precision = std::ratio<1>>
117template<
typename Unit,
typename Rep,
typename Precision>
124template<
typename Rep>
125concept not_quantity = !is_quantity_v<Rep>;
128struct _is_chrono_duration : std::false_type {};
130template<
typename Rep,
typename Period>
131struct _is_chrono_duration<
std::chrono::duration<Rep, Period>> : std::true_type {};
142concept duration_like = _is_chrono_duration<std::remove_cvref_t<T>>::value;
149template<
typename Rep>
152 static constexpr Rep
zero() noexcept {
return Rep(0); }
155 static constexpr Rep
max() noexcept {
return std::numeric_limits<Rep>::max(); }
158 static constexpr Rep
min() noexcept {
return std::numeric_limits<Rep>::lowest(); }
175 static constexpr const char*
symbol =
"V";
180 static constexpr const char*
symbol =
"A";
185 static constexpr const char*
symbol =
"Ω";
190 static constexpr const char*
symbol =
"W";
195 static constexpr const char*
symbol =
"C";
200 static constexpr const char*
symbol =
"J";
205 static constexpr const char*
symbol =
"F";
210 static constexpr const char*
symbol =
"H";
244template<
typename Unit,
typename Rep,
typename Precision>
246 static_assert(!is_quantity_v<Rep>,
"rep cannot be an quanta::electro::quantity");
247 static_assert(_is_ratio<Precision>::value,
"precision must be a specialization of std::ratio");
248 static_assert(Precision::num > 0,
"precision must be positive");
271 template<
typename Rep2>
272 requires std::convertible_to<const Rep2&, rep> && (treat_as_inexact_v<rep> || !treat_as_inexact_v<Rep2>)
274 : _r(
static_cast<rep>(r)) {}
290 template<
typename Rep2,
typename Precision2>
291 requires std::convertible_to<const Rep2&, rep> &&
292 detail::_lossless_conversion<Rep2, Precision2, rep, precision> &&
293 detail::_quantity_castable<quantity<Unit, Rep2, Precision2>,
quantity>
313 template<
typename Rep2,
typename Precision2>
314 requires(!detail::_lossless_conversion<Rep2, Precision2, rep, precision> ||
315 !std::convertible_to<const Rep2&, rep>) &&
318 : _r(quantity_cast<quantity>(q).
count()) {}
369 requires(!treat_as_inexact_v<rep>)
376 requires(!treat_as_inexact_v<rep>)
410template<
typename ToQuantity,
typename Unit,
typename Rep,
typename Precision>
411 requires(!std::is_same_v<typename ToQuantity::unit, Unit>) ||
412 detail::_quantity_cast_requirements<quantity<Unit, Rep, Precision>, ToQuantity>
416 std::is_same_v<typename ToQuantity::unit, Unit>,
"quantity_cast cannot convert between different units"
418 return detail::_quantity_cast<ToQuantity>(q);
440template<
typename ToQuantity,
typename Unit,
typename Rep,
typename Precision>
442 return detail::_floor_cast(quantity_cast<ToQuantity>(q), q);
464template<
typename ToQuantity,
typename Unit,
typename Rep,
typename Precision>
466 return detail::_ceil_cast(quantity_cast<ToQuantity>(q), q);
487template<
typename ToQuantity,
typename Unit,
typename Rep,
typename Precision>
489 return quantity_cast<ToQuantity>(q);
511template<
typename ToQuantity,
typename Unit,
typename Rep,
typename Precision>
513 return detail::_round_cast<ToQuantity>(q, [&q] {
return floor<ToQuantity>(q); });
526template<
typename Unit,
typename Rep,
typename Precision>
528 return detail::_abs(q);
536template<
typename Unit,
typename Rep1,
typename Precision1,
typename Rep2,
typename Precision2>
540 return cq(cq(lhs).count() + cq(rhs).count());
544template<
typename Unit,
typename Rep1,
typename Precision1,
typename Rep2,
typename Precision2>
548 return cq(cq(lhs).count() - cq(rhs).count());
552template<
typename Unit,
typename Rep1,
typename Precision,
typename Rep2>
553 requires not_quantity<Rep2> && std::convertible_to<const Rep2&, std::common_type_t<Rep1, Rep2>>
557 return cq(cq(q).count() * r);
561template<
typename Unit,
typename Rep1,
typename Rep2,
typename Precision>
562 requires not_quantity<Rep1> && std::convertible_to<const Rep1&, std::common_type_t<Rep1, Rep2>>
569template<
typename Unit,
typename Rep1,
typename Precision,
typename Rep2>
570 requires not_quantity<Rep2> && std::convertible_to<const Rep2&, std::common_type_t<Rep1, Rep2>>
574 return cq(cq(q).count() / s);
578template<
typename Unit,
typename Rep1,
typename Precision1,
typename Rep2,
typename Precision2>
580 -> std::common_type_t<Rep1, Rep2> {
582 return cq(lhs).
count() / cq(rhs).count();
586template<
typename Unit,
typename Rep1,
typename Precision,
typename Rep2>
587 requires not_quantity<Rep2> && std::convertible_to<const Rep2&, std::common_type_t<Rep1, Rep2>> &&
588 (!treat_as_inexact_v<Rep1> && !treat_as_inexact_v<Rep2>)
592 return cq(cq(q).count() % s);
596template<
typename Unit,
typename Rep1,
typename Precision1,
typename Rep2,
typename Precision2>
597 requires(!treat_as_inexact_v<Rep1> && !treat_as_inexact_v<Rep2>)
601 return cq(cq(lhs).count() % cq(rhs).count());
604template<
typename Unit,
typename Rep1,
typename Precision1,
typename Rep2,
typename Precision2>
607 return ct(lhs).
count() == ct(rhs).count();
610template<
typename Unit,
typename Rep1,
typename Precision1,
typename Rep2,
typename Precision2>
611 requires std::three_way_comparable<std::common_type_t<Rep1, Rep2>>
614 return ct(lhs).
count() <=> ct(rhs).count();
625template<
typename ToUnit,
typename U1,
typename R1,
typename P1,
typename U2,
typename R2,
typename P2>
626constexpr auto _product(
const quantity<U1, R1, P1>& lhs,
const quantity<U2, R2, P2>& rhs) {
627 using cr = std::common_type_t<R1, R2>;
628 using result_t = quantity<ToUnit, cr, std::ratio_multiply<P1, P2>>;
629 return result_t(
static_cast<cr
>(lhs.count()) *
static_cast<cr
>(rhs.count()));
634template<
typename ToUnit,
typename U1,
typename R1,
typename P1,
typename U2,
typename R2,
typename P2>
635constexpr auto _quotient(
const quantity<U1, R1, P1>& lhs,
const quantity<U2, R2, P2>& rhs) {
636 using cr = std::common_type_t<R1, R2>;
637 using result_t = quantity<ToUnit, cr, std::ratio_divide<P1, P2>>;
638 return result_t(
static_cast<cr
>(lhs.count()) /
static_cast<cr
>(rhs.count()));
642template<
typename ToUnit,
typename U1,
typename R1,
typename P1, duration_like D>
643constexpr auto _duration_product(
const quantity<U1, R1, P1>& lhs,
const D& rhs) {
644 using cr = std::common_type_t<R1, typename D::rep>;
645 using result_t = quantity<ToUnit, cr, std::ratio_multiply<P1, typename D::period>>;
646 return result_t(
static_cast<cr
>(lhs.count()) *
static_cast<cr
>(rhs.count()));
650template<
typename ToUnit,
typename U1,
typename R1,
typename P1, duration_like D>
651constexpr auto _duration_quotient(
const quantity<U1, R1, P1>& lhs,
const D& rhs) {
652 using cr = std::common_type_t<R1, typename D::rep>;
653 using result_t = quantity<ToUnit, cr, std::ratio_divide<P1, typename D::period>>;
654 return result_t(
static_cast<cr
>(lhs.count()) /
static_cast<cr
>(rhs.count()));
658template<
typename U1,
typename R1,
typename P1,
typename U2,
typename R2,
typename P2>
659constexpr auto _quotient_duration(
const quantity<U1, R1, P1>& lhs,
const quantity<U2, R2, P2>& rhs) {
660 using cr = std::common_type_t<R1, R2>;
661 using result_t = std::chrono::duration<cr, std::ratio_divide<P1, P2>>;
662 return result_t(
static_cast<cr
>(lhs.count()) /
static_cast<cr
>(rhs.count()));
666template<
typename U1,
typename R1,
typename P1,
typename U2,
typename R2,
typename P2>
667constexpr auto _product_duration(
const quantity<U1, R1, P1>& lhs,
const quantity<U2, R2, P2>& rhs) {
668 using cr = std::common_type_t<R1, R2>;
669 using result_t = std::chrono::duration<cr, std::ratio_multiply<P1, P2>>;
670 return result_t(
static_cast<cr
>(lhs.count()) *
static_cast<cr
>(rhs.count()));
686template<
typename R1,
typename P1,
typename R2,
typename P2>
688 return _product<volt_unit>(i, r);
692template<
typename R1,
typename P1,
typename R2,
typename P2>
694 return _product<volt_unit>(r, i);
698template<
typename R1,
typename P1,
typename R2,
typename P2>
700 return _quotient<ampere_unit>(v, r);
704template<
typename R1,
typename P1,
typename R2,
typename P2>
706 return _quotient<ohm_unit>(v, i);
710template<
typename R1,
typename P1,
typename R2,
typename P2>
712 return _product<watt_unit>(v, i);
716template<
typename R1,
typename P1,
typename R2,
typename P2>
718 return _product<watt_unit>(i, v);
722template<
typename R1,
typename P1,
typename R2,
typename P2>
724 return _quotient<ampere_unit>(p, v);
728template<
typename R1,
typename P1,
typename R2,
typename P2>
730 return _quotient<volt_unit>(p, i);
740template<
typename R1,
typename P1, duration_like D>
742 return _duration_product<coulomb_unit>(i, t);
746template<duration_like D,
typename R1,
typename P1>
748 return _duration_product<coulomb_unit>(i, t);
752template<
typename R1,
typename P1, duration_like D>
754 return _duration_quotient<ampere_unit>(q, t);
764template<
typename R1,
typename P1,
typename R2,
typename P2>
766 return _quotient_duration(q, i);
776template<
typename R1,
typename P1, duration_like D>
778 return _duration_product<joule_unit>(p, t);
782template<duration_like D,
typename R1,
typename P1>
784 return _duration_product<joule_unit>(p, t);
788template<
typename R1,
typename P1, duration_like D>
790 return _duration_quotient<watt_unit>(e, t);
794template<
typename R1,
typename P1,
typename R2,
typename P2>
796 return _quotient_duration(e, p);
806template<
typename R1,
typename P1,
typename R2,
typename P2>
808 return _quotient<coulomb_unit>(e, v);
812template<
typename R1,
typename P1,
typename R2,
typename P2>
814 return _quotient<volt_unit>(e, q);
818template<
typename R1,
typename P1,
typename R2,
typename P2>
820 return _product<coulomb_unit>(c, v);
824template<
typename R1,
typename P1,
typename R2,
typename P2>
826 return _product<coulomb_unit>(v, c);
830template<
typename R1,
typename P1,
typename R2,
typename P2>
832 return _quotient<farad_unit>(q, v);
836template<
typename R1,
typename P1,
typename R2,
typename P2>
838 return _quotient<volt_unit>(q, c);
848template<
typename R1,
typename P1,
typename R2,
typename P2>
850 return _product_duration(r, c);
854template<
typename R1,
typename P1,
typename R2,
typename P2>
856 return _product_duration(c, r);
866template<
typename R1,
typename P1,
typename R2,
typename P2>
868 return _quotient_duration(l, r);
887template<
typename Rep,
typename Precision = std::ratio<1>>
891template<
typename Rep,
typename Precision = std::ratio<1>>
895template<
typename Rep,
typename Precision = std::ratio<1>>
899template<
typename Rep,
typename Precision = std::ratio<1>>
903template<
typename Rep,
typename Precision = std::ratio<1>>
907template<
typename Rep,
typename Precision = std::ratio<1>>
911template<
typename Rep,
typename Precision = std::ratio<1>>
915template<
typename Rep,
typename Precision = std::ratio<1>>
1020template<
typename Precision>
1026 static constexpr const char* symbol =
"f";
1031 static constexpr const char* symbol =
"p";
1035struct si_prefix<
std::nano> {
1036 static constexpr const char* symbol =
"n";
1040struct si_prefix<
std::micro> {
1041 static constexpr const char* symbol =
"µ";
1045struct si_prefix<
std::milli> {
1046 static constexpr const char* symbol =
"m";
1050struct si_prefix<
std::ratio<1>> {
1051 static constexpr const char* symbol =
"";
1055struct si_prefix<
std::kilo> {
1056 static constexpr const char* symbol =
"k";
1060struct si_prefix<
std::mega> {
1061 static constexpr const char* symbol =
"M";
1065struct si_prefix<
std::giga> {
1066 static constexpr const char* symbol =
"G";
1070struct si_prefix<
std::tera> {
1071 static constexpr const char* symbol =
"T";
1086template<
typename Unit,
typename Precision>
1098struct quantity_suffix<coulomb_unit,
std::ratio<18, 5>> {
1099 static std::string
value() {
return "mAh"; }
1103struct quantity_suffix<coulomb_unit,
std::ratio<3600>> {
1104 static std::string
value() {
return "Ah"; }
1108struct quantity_suffix<joule_unit,
std::ratio<3600>> {
1109 static std::string
value() {
return "Wh"; }
1113struct quantity_suffix<joule_unit,
std::ratio<3600000>> {
1114 static std::string
value() {
return "kWh"; }
1117template<
typename Unit,
typename Precision>
1124template<
typename Unit,
typename Precision>
1125struct _base_display_unit {
1126 using scale = std::ratio<1>;
1127 static constexpr const char* suffix = Unit::symbol;
1130struct _ampere_hour_display_unit {
1131 using scale = std::ratio<3600>;
1132 static constexpr const char* suffix =
"Ah";
1135struct _watt_hour_display_unit {
1136 using scale = std::ratio<3600>;
1137 static constexpr const char* suffix =
"Wh";
1141struct _base_display_unit<coulomb_unit,
std::ratio<18, 5>> : _ampere_hour_display_unit {};
1144struct _base_display_unit<coulomb_unit,
std::ratio<3600>> : _ampere_hour_display_unit {};
1147struct _base_display_unit<joule_unit,
std::ratio<3600>> : _watt_hour_display_unit {};
1150struct _base_display_unit<joule_unit,
std::ratio<3600000>> : _watt_hour_display_unit {};
1159template<
typename Unit,
typename Rep,
typename Precision>
1160_display _base_unit_display(
const quantity<Unit, Rep, Precision>& q) {
1161 using display = _base_display_unit<Unit, typename Precision::type>;
1163 using upc =
typename std::ratio_divide<typename Precision::type, typename display::scale>::type;
1164 return {detail::_ratio_value<upc>(q.count()), display::suffix};
1168template<
typename Precision>
1169concept _si_precision =
requires { si_prefix<Precision>::symbol; } && detail::_power_of_ten_precision<Precision>;
1177template<
typename Unit,
typename Rep,
typename Precision>
1178_display _scaled_display(
const quantity<Unit, Rep, Precision>& q) {
1179 using p =
typename Precision::type;
1180 const double count =
static_cast<double>(q.count());
1181 if constexpr (_si_precision<p>) {
1182 if (count == 0 || !std::isfinite(count)) {
1183 return _base_unit_display(q);
1186 const detail::_scaled s = detail::_pick_scale(count, _precision_exponent<p>, detail::_si_scale);
1187 return {s.value, std::string(s.label) + Unit::symbol};
1193#if CONFIG_QUANTA_STD_FORMAT
1196template<
typename Unit,
typename Precision>
1197struct _format_traits {
1198 static constexpr const char* markers =
"bs";
1199 static constexpr bool has_own_unit =
true;
1201 static std::string own_unit(
bool) {
1202 const std::string suffix = quantity_suffix<Unit, Precision>::value();
1206 template<
typename OutputIt>
1207 static OutputIt append_own_unit(OutputIt out,
const std::string& suffix) {
1208 return std::format_to(out,
"{}", suffix);
1211 template<
typename Q>
1212 static _display base_display(
const Q& q) {
1213 return _base_unit_display(q);
1216 template<
typename Q>
1217 static _display scaled_display(
const Q& q) {
1218 return _scaled_display(q);
1221 template<
typename OutputIt>
1222 static OutputIt append_label(OutputIt out,
const _display& d) {
1223 return std::format_to(out,
"{}", d.suffix);
1285template<
typename Unit,
typename Rep,
typename Precision>
1286 requires _has_suffix<Unit, typename Precision::type>
1301template<
typename Unit,
typename Rep,
typename Precision>
1302 requires _has_suffix<Unit, typename Precision::type>
1304 const _display d = _base_unit_display(q);
1305 return _fixed_string(d.value) + d.suffix;
1318template<
typename Unit,
typename Rep,
typename Precision>
1319 requires _has_suffix<Unit, typename Precision::type>
1321 const _display d = _scaled_display(q);
1322 return _fixed_string(d.value) + d.suffix;
1329template<
typename Unit,
typename Rep1,
typename Precision1,
typename Rep2,
typename Precision2>
1331 quanta::electro::quantity<Unit, Rep1, Precision1>,
1334 using common_precision = quanta::detail::_common_precision<Precision1, Precision2>;
1340#if CONFIG_QUANTA_STD_FORMAT
1364template<
typename Unit,
typename Rep,
typename Precision>
1365 requires quanta::electro::_has_suffix<Unit, typename Precision::type>
1366struct formatter<
quanta::electro::quantity<Unit, Rep, Precision>, char>
1367 :
private quanta::detail::_unit_formatter<quanta::electro::_format_traits<Unit, typename Precision::type>> {
1368 using quanta::detail::_unit_formatter<quanta::electro::_format_traits<Unit, typename Precision::type>>::parse;
1370 template<
typename FormatContext>
1372 return this->format_quantity(q, ctx);
1383inline namespace literals {
1384inline namespace electro_literals {
1451#if QUANTA_HAS_UTF8_LITERALS
1607using namespace literals::electro_literals;
A quantity of an electrical unit with a representation and precision.
constexpr quantity operator--(int)
static constexpr quantity zero() noexcept
Returns a zero quantity.
static constexpr quantity min() noexcept
Returns the minimum representable quantity.
constexpr quantity operator++(int)
Rep rep
The representation type.
constexpr quantity(const Rep2 &r)
Constructs from a tick count.
constexpr quantity & operator%=(const quantity &q)
static constexpr quantity max() noexcept
Returns the maximum representable quantity.
typename Precision::type precision
The precision as a std::ratio.
constexpr quantity & operator--()
constexpr quantity< Unit, typename std::common_type< rep >::type, precision > operator+() const
constexpr quantity< Unit, typename std::common_type< rep >::type, precision > operator-() const
quantity & operator=(const quantity &)=default
constexpr quantity()=default
Constructs a zero quantity.
quantity(const quantity &)=default
constexpr rep count() const
Returns the tick count.
constexpr quantity & operator*=(const rep &r)
constexpr quantity & operator-=(const quantity &q)
constexpr quantity & operator/=(const rep &r)
Unit unit
The unit tag type.
constexpr quantity & operator%=(const rep &r)
constexpr quantity & operator+=(const quantity &q)
constexpr quantity(const quantity< Unit, Rep2, Precision2 > &q)
Constructs from another quantity of the same unit with different representation or precision.
constexpr quantity(const quantity< Unit, Rep2, Precision2 > &q)
Explicit constructor for lossy conversions.
constexpr quantity & operator++()
Configuration, traits and internals shared by every quanta domain.
quantity< joule_unit, Rep, Precision > energy
Energy quantity with configurable representation and precision.
capacitance< int64_t, std::nano > nanofarads
Capacitance with 1 nF precision.
microamperes microamps
Shorthand for microamperes.
power< int64_t, std::giga > gigawatts
Power with 1 GW precision.
power< int64_t, std::mega > megawatts
Power with 1 MW precision.
capacitance< int64_t, std::pico > picofarads
Capacitance with 1 pF precision.
quantity< coulomb_unit, Rep, Precision > charge
Charge quantity with configurable representation and precision.
energy< int64_t, std::ratio< 3600 > > watt_hours
Energy with 1 Wh (3600 J) precision.
inductance< int64_t, std::nano > nanohenries
Inductance with 1 nH precision.
power< int64_t, std::kilo > kilowatts
Power with 1 kW precision.
quantity< henry_unit, Rep, Precision > inductance
Inductance quantity with configurable representation and precision.
energy< int64_t, std::milli > millijoules
Energy with 1 mJ precision.
voltage< int64_t > volts
Voltage with 1 V precision.
amperes amps
Shorthand for amperes.
charge< int64_t, std::milli > millicoulombs
Charge with 1 mC precision.
quantity< volt_unit, Rep, Precision > voltage
Voltage quantity with configurable representation and precision.
power< int64_t > watts
Power with 1 W precision.
power< int64_t, std::milli > milliwatts
Power with 1 mW precision.
energy< int64_t > joules
Energy with 1 J precision.
quantity< ohm_unit, Rep, Precision > resistance
Resistance quantity with configurable representation and precision.
voltage< int64_t, std::micro > microvolts
Voltage with 1 µV precision.
current< int64_t, std::milli > milliamperes
Current with 1 mA precision.
capacitance< int64_t, std::micro > microfarads
Capacitance with 1 µF precision.
inductance< int64_t, std::milli > millihenries
Inductance with 1 mH precision.
quantity< farad_unit, Rep, Precision > capacitance
Capacitance quantity with configurable representation and precision.
energy< int64_t, std::mega > megajoules
Energy with 1 MJ precision.
charge< int64_t, std::ratio< 18, 5 > > milliampere_hours
Charge with 1 mAh (3.6 C) precision.
charge< int64_t, std::ratio< 3600 > > ampere_hours
Charge with 1 Ah (3600 C) precision.
resistance< int64_t, std::giga > gigaohms
Resistance with 1 GΩ precision.
voltage< int64_t, std::kilo > kilovolts
Voltage with 1 kV precision.
quantity< watt_unit, Rep, Precision > power
Power quantity with configurable representation and precision.
energy< int64_t, std::kilo > kilojoules
Energy with 1 kJ precision.
current< int64_t, std::micro > microamperes
Current with 1 µA precision.
voltage< int64_t, std::milli > millivolts
Voltage with 1 mV precision.
inductance< int64_t, std::micro > microhenries
Inductance with 1 µH precision.
resistance< int64_t, std::kilo > kiloohms
Resistance with 1 kΩ precision.
charge< int64_t, std::micro > microcoulombs
Charge with 1 µC precision.
power< int64_t, std::micro > microwatts
Power with 1 µW precision.
capacitance< int64_t, std::milli > millifarads
Capacitance with 1 mF precision.
resistance< int64_t, std::milli > milliohms
Resistance with 1 mΩ precision.
current< int64_t > amperes
Current with 1 A precision.
milliamperes milliamps
Shorthand for milliamperes.
energy< int64_t, std::ratio< 3600000 > > kilowatt_hours
Energy with 1 kWh (3,600,000 J) precision.
charge< int64_t > coulombs
Charge with 1 C precision.
capacitance< int64_t > farads
Capacitance with 1 F precision.
inductance< int64_t > henries
Inductance with 1 H precision.
resistance< int64_t > ohms
Resistance with 1 Ω precision.
resistance< int64_t, std::mega > megaohms
Resistance with 1 MΩ precision.
quantity< ampere_unit, Rep, Precision > current
Current quantity with configurable representation and precision.
Electrical unit types and utilities.
constexpr auto operator*(const quantity< Unit, Rep1, Precision > &q, const Rep2 &r) -> quantity< Unit, std::common_type_t< Rep1, Rep2 >, Precision >
Multiplies a quantity by a scalar.
constexpr ToLevel ceil(const level< Reference, Rep, Precision > &l)
Converts a level to the target type, rounding toward positive infinity.
constexpr auto operator/(const quantity< Unit, Rep1, Precision > &q, const Rep2 &s) -> quantity< Unit, std::common_type_t< Rep1, Rep2 >, Precision >
Divides a quantity by a scalar.
constexpr bool is_quantity_v
constexpr auto operator-(const level< Reference, Rep1, Precision1 > &l, const quantity< decibel_unit, Rep2, Precision2 > &g)
Applies a loss to a level.
constexpr ToQuantity quantity_cast(const quantity< Unit, Rep, Precision > &q)
Converts a quantity to a different precision or representation.
constexpr ToLevel round(const level< Reference, Rep, Precision > &l)
Converts a level to the target type, rounding to nearest (ties to even).
constexpr ToLevel trunc(const level< Reference, Rep, Precision > &l)
Converts a level to the target type, rounding toward zero (as level_cast does).
std::string to_string(const quantity< decibel_unit, Rep, Precision > &g)
Converts a gain to a string, e.g.
constexpr quantity< Unit, Rep, Precision > abs(const quantity< Unit, Rep, Precision > &q)
Returns the absolute value of a quantity.
constexpr auto operator<=>(const level< Reference, Rep1, Precision1 > &a, const level< Reference, Rep2, Precision2 > &b)
constexpr bool operator==(const level< Reference, Rep1, Precision1 > &a, const level< Reference, Rep2, Precision2 > &b)
constexpr auto operator+(const level< Reference, Rep1, Precision1 > &l, const quantity< decibel_unit, Rep2, Precision2 > &g)
Applies a gain to a level.
constexpr ToLevel floor(const level< Reference, Rep, Precision > &l)
Converts a level to the target type, rounding toward negative infinity.
Type-safe units modeled after std::chrono.
constexpr scaled_t scaled
Selects the scaled form in to_string().
constexpr base_unit_t base_unit
Selects the base-unit form in to_string().
constexpr bool treat_as_inexact_v
Tag type selecting the base-unit form, see base_unit.
Electric current, measured in amperes.
static constexpr const char * symbol
Electric charge, measured in coulombs.
static constexpr const char * symbol
Capacitance, measured in farads.
static constexpr const char * symbol
Inductance, measured in henries.
static constexpr const char * symbol
Trait to detect quantity specializations.
Energy, measured in joules.
static constexpr const char * symbol
Electrical resistance, measured in ohms.
static constexpr const char * symbol
Trait giving the display suffix for a (unit, precision) pair.
static std::string value()
Returns the display suffix.
Provides special values for quantity representations.
static constexpr Rep max() noexcept
Returns the maximum representable quantity.
static constexpr Rep zero() noexcept
Returns a zero quantity.
static constexpr Rep min() noexcept
Returns the minimum representable quantity.
Trait giving the display symbol for an SI precision prefix.
Voltage, measured in volts.
static constexpr const char * symbol
Power, measured in watts.
static constexpr const char * symbol
Tag type selecting the scaled form, see scaled.
Trait to indicate floating-point-like behavior.
quanta::electro::quantity< Unit, std::common_type_t< Rep1, Rep2 >, common_precision > type