106template<
typename Unit,
typename Rep,
typename Precision = std::ratio<1>>
116template<
typename Unit,
typename Rep,
typename Precision>
123template<
typename Rep>
124concept not_quantity = !is_quantity_v<Rep>;
131template<
typename Rep>
134 static constexpr Rep
zero() noexcept {
return Rep(0); }
137 static constexpr Rep
max() noexcept {
return std::numeric_limits<Rep>::max(); }
140 static constexpr Rep
min() noexcept {
return std::numeric_limits<Rep>::lowest(); }
160 static constexpr const char*
symbol =
"m";
165 static constexpr const char*
symbol =
"m²";
170 static constexpr const char*
symbol =
"m³";
181template<
typename Unit,
typename Precision>
182struct _period_base {};
184template<
typename Precision>
185 requires _is_ratio<Precision>::value
186struct _period_base<meter_unit, Precision> {
187 using period =
typename Precision::type;
230template<
typename Unit,
typename Rep,
typename Precision>
231class quantity :
public _period_base<Unit, Precision> {
232 static_assert(!is_quantity_v<Rep>,
"rep cannot be a quanta::spatial::quantity");
233 static_assert(_is_ratio<Precision>::value,
"precision must be a specialization of std::ratio");
234 static_assert(Precision::num > 0,
"precision must be positive");
257 template<
typename Rep2>
258 requires std::convertible_to<const Rep2&, rep> && (treat_as_inexact_v<rep> || !treat_as_inexact_v<Rep2>)
260 : _r(
static_cast<rep>(r)) {}
276 template<
typename Rep2,
typename Precision2>
277 requires std::convertible_to<const Rep2&, rep> &&
278 detail::_lossless_conversion<Rep2, Precision2, rep, precision> &&
279 detail::_quantity_castable<quantity<Unit, Rep2, Precision2>,
quantity>
299 template<
typename Rep2,
typename Precision2>
300 requires(!detail::_lossless_conversion<Rep2, Precision2, rep, precision> ||
301 !std::convertible_to<const Rep2&, rep>) &&
304 : _r(quantity_cast<quantity>(q).
count()) {}
357 requires(!treat_as_inexact_v<rep>)
364 requires(!treat_as_inexact_v<rep>)
404template<
typename ToQuantity,
typename Unit,
typename Rep,
typename Precision>
405 requires(!std::is_same_v<typename ToQuantity::unit, Unit>) ||
406 detail::_quantity_cast_requirements<quantity<Unit, Rep, Precision>, ToQuantity>
410 std::is_same_v<typename ToQuantity::unit, Unit>,
"quantity_cast cannot convert between different units"
412 return detail::_quantity_cast<ToQuantity>(q);
434template<
typename ToQuantity,
typename Unit,
typename Rep,
typename Precision>
436 return detail::_floor_cast(quantity_cast<ToQuantity>(q), q);
458template<
typename ToQuantity,
typename Unit,
typename Rep,
typename Precision>
460 return detail::_ceil_cast(quantity_cast<ToQuantity>(q), q);
481template<
typename ToQuantity,
typename Unit,
typename Rep,
typename Precision>
483 return quantity_cast<ToQuantity>(q);
505template<
typename ToQuantity,
typename Unit,
typename Rep,
typename Precision>
507 return detail::_round_cast<ToQuantity>(q, [&q] {
return floor<ToQuantity>(q); });
520template<
typename Unit,
typename Rep,
typename Precision>
522 return detail::_abs(q);
530template<
typename Unit,
typename Rep1,
typename Precision1,
typename Rep2,
typename Precision2>
534 return cq(cq(lhs).count() + cq(rhs).count());
538template<
typename Unit,
typename Rep1,
typename Precision1,
typename Rep2,
typename Precision2>
542 return cq(cq(lhs).count() - cq(rhs).count());
546template<
typename Unit,
typename Rep1,
typename Precision,
typename Rep2>
547 requires not_quantity<Rep2> && std::convertible_to<const Rep2&, std::common_type_t<Rep1, Rep2>>
551 return cq(cq(q).count() * r);
555template<
typename Unit,
typename Rep1,
typename Rep2,
typename Precision>
556 requires not_quantity<Rep1> && std::convertible_to<const Rep1&, std::common_type_t<Rep1, Rep2>>
563template<
typename Unit,
typename Rep1,
typename Precision,
typename Rep2>
564 requires not_quantity<Rep2> && std::convertible_to<const Rep2&, std::common_type_t<Rep1, Rep2>>
568 return cq(cq(q).count() / s);
572template<
typename Unit,
typename Rep1,
typename Precision1,
typename Rep2,
typename Precision2>
574 -> std::common_type_t<Rep1, Rep2> {
576 return cq(lhs).
count() / cq(rhs).count();
580template<
typename Unit,
typename Rep1,
typename Precision,
typename Rep2>
581 requires not_quantity<Rep2> && std::convertible_to<const Rep2&, std::common_type_t<Rep1, Rep2>> &&
582 (!treat_as_inexact_v<Rep1> && !treat_as_inexact_v<Rep2>)
586 return cq(cq(q).count() % s);
590template<
typename Unit,
typename Rep1,
typename Precision1,
typename Rep2,
typename Precision2>
591 requires(!treat_as_inexact_v<Rep1> && !treat_as_inexact_v<Rep2>)
595 return cq(cq(lhs).count() % cq(rhs).count());
598template<
typename Unit,
typename Rep1,
typename Precision1,
typename Rep2,
typename Precision2>
601 return ct(lhs).
count() == ct(rhs).count();
604template<
typename Unit,
typename Rep1,
typename Precision1,
typename Rep2,
typename Precision2>
605 requires std::three_way_comparable<std::common_type_t<Rep1, Rep2>>
608 return ct(lhs).
count() <=> ct(rhs).count();
619template<
typename ToUnit,
typename U1,
typename R1,
typename P1,
typename U2,
typename R2,
typename P2>
620constexpr auto _product(
const quantity<U1, R1, P1>& lhs,
const quantity<U2, R2, P2>& rhs) {
621 using cr = std::common_type_t<R1, R2>;
622 using result_t = quantity<ToUnit, cr, std::ratio_multiply<P1, P2>>;
623 return result_t(
static_cast<cr
>(lhs.count()) *
static_cast<cr
>(rhs.count()));
628template<
typename ToUnit,
typename U1,
typename R1,
typename P1,
typename U2,
typename R2,
typename P2>
629constexpr auto _quotient(
const quantity<U1, R1, P1>& lhs,
const quantity<U2, R2, P2>& rhs) {
630 using cr = std::common_type_t<R1, R2>;
631 using result_t = quantity<ToUnit, cr, std::ratio_divide<P1, P2>>;
632 return result_t(
static_cast<cr
>(lhs.count()) /
static_cast<cr
>(rhs.count()));
660template<
typename R1,
typename P1,
typename R2,
typename P2>
662 return _product<square_meter_unit>(lhs, rhs);
666template<
typename R1,
typename P1,
typename R2,
typename P2>
668 return _product<cubic_meter_unit>(lhs, rhs);
672template<
typename R1,
typename P1,
typename R2,
typename P2>
674 return _product<cubic_meter_unit>(lhs, rhs);
678template<
typename R1,
typename P1,
typename R2,
typename P2>
680 return _quotient<meter_unit>(lhs, rhs);
684template<
typename R1,
typename P1,
typename R2,
typename P2>
686 return _quotient<square_meter_unit>(lhs, rhs);
690template<
typename R1,
typename P1,
typename R2,
typename P2>
693 return _quotient<meter_unit>(lhs, rhs);
719template<
typename Rep,
typename Precision = std::ratio<1>>
749template<
typename Rep,
typename Precision = std::ratio<1>>
775template<
typename Rep,
typename Precision = std::ratio<1>>
813template<
typename Precision>
819 static constexpr const char* symbol =
"f";
824 static constexpr const char* symbol =
"p";
828struct si_prefix<
std::nano> {
829 static constexpr const char* symbol =
"n";
833struct si_prefix<
std::micro> {
834 static constexpr const char* symbol =
"µ";
838struct si_prefix<
std::milli> {
839 static constexpr const char* symbol =
"m";
843struct si_prefix<
std::centi> {
844 static constexpr const char* symbol =
"c";
848struct si_prefix<
std::ratio<1>> {
849 static constexpr const char* symbol =
"";
853struct si_prefix<
std::kilo> {
854 static constexpr const char* symbol =
"k";
858struct si_prefix<
std::mega> {
859 static constexpr const char* symbol =
"M";
863struct si_prefix<
std::giga> {
864 static constexpr const char* symbol =
"G";
868struct si_prefix<
std::tera> {
869 static constexpr const char* symbol =
"T";
908template<
typename Unit,
typename Precision>
920using _square_ratio = std::ratio_multiply<R, R>;
923using _cube_ratio = std::ratio_multiply<std::ratio_multiply<R, R>, R>;
927template<
typename Precision>
928struct quantity_suffix<square_meter_unit, Precision> {};
930template<
typename Precision>
931struct quantity_suffix<cubic_meter_unit, Precision> {};
934struct quantity_suffix<meter_unit,
std::ratio<127, 5000000>> {
935 static std::string
value() {
return "mil"; }
939struct quantity_suffix<meter_unit,
std::ratio<127, 5000>> {
940 static std::string
value() {
return "in"; }
944struct quantity_suffix<meter_unit,
std::ratio<381, 1250>> {
945 static std::string
value() {
return "ft"; }
949struct quantity_suffix<meter_unit,
std::ratio<1143, 1250>> {
950 static std::string
value() {
return "yd"; }
954struct quantity_suffix<meter_unit,
std::ratio<201168, 125>> {
955 static std::string
value() {
return "mi"; }
959struct quantity_suffix<meter_unit,
std::ratio<1852>> {
960 static std::string
value() {
return "nmi"; }
965struct quantity_suffix<square_meter_unit, _square_ratio<
std::nano>> {
966 static std::string
value() {
return "nm²"; }
970struct quantity_suffix<square_meter_unit, _square_ratio<
std::micro>> {
971 static std::string
value() {
return "µm²"; }
975struct quantity_suffix<square_meter_unit, _square_ratio<
std::milli>> {
976 static std::string
value() {
return "mm²"; }
980struct quantity_suffix<square_meter_unit, _square_ratio<
std::centi>> {
981 static std::string
value() {
return "cm²"; }
985struct quantity_suffix<square_meter_unit,
std::ratio<1>> {
986 static std::string
value() {
return "m²"; }
990struct quantity_suffix<square_meter_unit, _square_ratio<
std::hecto>> {
991 static std::string
value() {
return "ha"; }
992 static std::string power_value() {
return "hm²"; }
996struct quantity_suffix<square_meter_unit, _square_ratio<
std::kilo>> {
997 static std::string
value() {
return "km²"; }
1001struct quantity_suffix<square_meter_unit, _square_ratio<
mils::precision>> {
1002 static std::string
value() {
return "mil²"; }
1006struct quantity_suffix<square_meter_unit, _square_ratio<
inches::precision>> {
1007 static std::string
value() {
return "in²"; }
1011struct quantity_suffix<square_meter_unit, _square_ratio<
feet::precision>> {
1012 static std::string
value() {
return "ft²"; }
1016struct quantity_suffix<square_meter_unit, _square_ratio<
yards::precision>> {
1017 static std::string
value() {
return "yd²"; }
1021struct quantity_suffix<square_meter_unit,
acres::precision> {
1022 static std::string
value() {
return "ac"; }
1026struct quantity_suffix<square_meter_unit, _square_ratio<
miles::precision>> {
1027 static std::string
value() {
return "mi²"; }
1031struct quantity_suffix<square_meter_unit, _square_ratio<
nautical_miles::precision>> {
1032 static std::string
value() {
return "nmi²"; }
1037struct quantity_suffix<cubic_meter_unit, _cube_ratio<
std::micro>> {
1038 static std::string
value() {
return "µm³"; }
1042struct quantity_suffix<cubic_meter_unit, _cube_ratio<
std::milli>> {
1043 static std::string
value() {
return "µL"; }
1044 static std::string power_value() {
return "mm³"; }
1048struct quantity_suffix<cubic_meter_unit, _cube_ratio<
std::centi>> {
1049 static std::string
value() {
return "mL"; }
1050 static std::string power_value() {
return "cm³"; }
1054struct quantity_suffix<cubic_meter_unit, _cube_ratio<
std::deci>> {
1055 static std::string
value() {
return "L"; }
1056 static std::string power_value() {
return "dm³"; }
1060struct quantity_suffix<cubic_meter_unit,
std::ratio<1>> {
1061 static std::string
value() {
return "m³"; }
1065struct quantity_suffix<cubic_meter_unit, _cube_ratio<
std::kilo>> {
1066 static std::string
value() {
return "km³"; }
1070struct quantity_suffix<cubic_meter_unit, _cube_ratio<
inches::precision>> {
1071 static std::string
value() {
return "in³"; }
1075struct quantity_suffix<cubic_meter_unit, _cube_ratio<
feet::precision>> {
1076 static std::string
value() {
return "ft³"; }
1080struct quantity_suffix<cubic_meter_unit, _cube_ratio<
yards::precision>> {
1081 static std::string
value() {
return "yd³"; }
1085struct quantity_suffix<cubic_meter_unit, _cube_ratio<
miles::precision>> {
1086 static std::string
value() {
return "mi³"; }
1090struct quantity_suffix<cubic_meter_unit, _cube_ratio<
nautical_miles::precision>> {
1091 static std::string
value() {
return "nmi³"; }
1095struct quantity_suffix<cubic_meter_unit,
us_gallons::precision> {
1096 static std::string
value() {
return "gal"; }
1099template<
typename Unit,
typename Precision>
1104template<
typename Unit,
typename Precision>
1105std::string _power_suffix() {
1106 if constexpr (
requires { quantity_suffix<Unit, Precision>::power_value(); }) {
1107 return quantity_suffix<Unit, Precision>::power_value();
1121template<
typename Precision>
1122concept _metric_precision = detail::_power_of_ten_precision<Precision>;
1127template<
typename Unit>
1128struct _scale_units {};
1131struct _scale_units<meter_unit> {
1132 static constexpr detail::_scale_entry values[] = {{-9,
"nm"}, {-6,
"µm"}, {-3,
"mm"}, {0,
"m"}, {3,
"km"}};
1136struct _scale_units<square_meter_unit> {
1137 static constexpr detail::_scale_entry values[] = {{-18,
"nm²"}, {-12,
"µm²"}, {-6,
"mm²"}, {0,
"m²"}, {6,
"km²"}};
1141struct _scale_units<cubic_meter_unit> {
1142 static constexpr detail::_scale_entry values[] = {{-9,
"µL"}, {-6,
"mL"}, {-3,
"L"}, {0,
"m³"}};
1146template<
typename Unit,
typename Rep,
typename Precision>
1147_display _base_unit_display(
const quantity<Unit, Rep, Precision>& q) {
1148 using p =
typename Precision::type;
1149 return {detail::_ratio_value<p>(q.count()), Unit::symbol};
1158template<
typename Unit,
typename Rep,
typename Precision>
1159_display _scaled_display(
const quantity<Unit, Rep, Precision>& q) {
1160 using p =
typename Precision::type;
1161 const double count =
static_cast<double>(q.count());
1162 if constexpr (_metric_precision<p> &&
requires { _scale_units<Unit>::values; }) {
1163 if (count == 0 || !std::isfinite(count)) {
1164 return {count, Unit::symbol};
1166 const detail::_scaled s = detail::_pick_scale(count, _precision_exponent<p>, _scale_units<Unit>::values);
1167 return {s.value, s.label};
1173#if CONFIG_QUANTA_STD_FORMAT
1176template<
typename Unit,
typename Precision>
1177struct _format_traits {
1178 static constexpr const char* markers =
"pbs";
1179 static constexpr bool has_own_unit =
true;
1181 static std::string own_unit(
bool power) {
1182 const std::string suffix =
power ? _power_suffix<Unit, Precision>() : quantity_suffix<Unit, Precision>::value();
1186 template<
typename OutputIt>
1187 static OutputIt append_own_unit(OutputIt out,
const std::string& suffix) {
1188 return std::format_to(out,
"{}", suffix);
1191 template<
typename Q>
1192 static _display base_display(
const Q& q) {
1193 return _base_unit_display(q);
1196 template<
typename Q>
1197 static _display scaled_display(
const Q& q) {
1198 return _scaled_display(q);
1201 template<
typename OutputIt>
1202 static OutputIt append_label(OutputIt out,
const _display& d) {
1203 return std::format_to(out,
"{}", d.suffix);
1292template<
typename Unit,
typename Rep,
typename Precision>
1293 requires _has_suffix<Unit, typename Precision::type>
1309template<
typename Unit,
typename Rep,
typename Precision>
1310 requires _has_suffix<Unit, typename Precision::type>
1312 return _count_string(q.
count()) + _power_suffix<Unit, typename Precision::type>();
1325template<
typename Unit,
typename Rep,
typename Precision>
1326 requires _has_suffix<Unit, typename Precision::type>
1328 const _display d = _base_unit_display(q);
1329 return _fixed_string(d.value) + d.suffix;
1342template<
typename Unit,
typename Rep,
typename Precision>
1343 requires _has_suffix<Unit, typename Precision::type>
1345 const _display d = _scaled_display(q);
1346 return _fixed_string(d.value) + d.suffix;
1353template<
typename Unit,
typename Rep1,
typename Precision1,
typename Rep2,
typename Precision2>
1355 quanta::spatial::quantity<Unit, Rep1, Precision1>,
1358 using common_precision = quanta::detail::_common_precision<Precision1, Precision2>;
1364#if CONFIG_QUANTA_STD_FORMAT
1390template<
typename Unit,
typename Rep,
typename Precision>
1391 requires quanta::spatial::_has_suffix<Unit, typename Precision::type>
1392struct formatter<
quanta::spatial::quantity<Unit, Rep, Precision>, char>
1393 :
private quanta::detail::_unit_formatter<quanta::spatial::_format_traits<Unit, typename Precision::type>> {
1394 using quanta::detail::_unit_formatter<quanta::spatial::_format_traits<Unit, typename Precision::type>>::parse;
1396 template<
typename FormatContext>
1398 return this->format_quantity(q, ctx);
1409inline namespace literals {
1410inline namespace spatial_literals {
1423#if QUANTA_HAS_UTF8_LITERALS
1557#if QUANTA_HAS_UTF8_LITERALS
1623using namespace literals::spatial_literals;
A quantity of a spatial unit with a representation and precision.
constexpr quantity & operator%=(const rep &r)
Rep rep
The representation type.
constexpr rep count() const
Returns the tick count.
constexpr quantity & operator%=(const quantity &q)
constexpr quantity & operator++()
quantity & operator=(const quantity &)=default
constexpr quantity(const quantity< Unit, Rep2, Precision2 > &q)
Constructs from another quantity of the same unit with different representation or precision.
Unit unit
The unit tag type.
static constexpr quantity zero() noexcept
Returns a zero quantity.
typename Precision::type precision
The precision as a std::ratio.
constexpr quantity()=default
Constructs a zero quantity.
constexpr quantity & operator+=(const quantity &q)
constexpr quantity & operator-=(const quantity &q)
constexpr quantity & operator/=(const rep &r)
constexpr quantity & operator--()
quantity(const quantity &)=default
constexpr quantity< Unit, typename std::common_type< rep >::type, precision > operator-() const
Returns the negation of this quantity.
constexpr quantity operator--(int)
constexpr quantity(const Rep2 &r)
Constructs from a tick count.
constexpr quantity< Unit, typename std::common_type< rep >::type, precision > operator+() const
Returns a copy of this quantity.
constexpr quantity(const quantity< Unit, Rep2, Precision2 > &q)
Explicit constructor for lossy conversions.
static constexpr quantity min() noexcept
Returns the minimum representable quantity.
constexpr quantity operator++(int)
static constexpr quantity max() noexcept
Returns the maximum representable quantity.
constexpr quantity & operator*=(const rep &r)
Configuration, traits and internals shared by every quanta domain.
quantity< watt_unit, Rep, Precision > power
Power quantity with configurable representation and precision.
length< int64_t, std::ratio< 201168, 125 > > miles
Length with 1 mi (5280 ft = 1609.344 m) precision.
area< int64_t, std::mega > square_kilometers
Area with 1 km² precision.
area< int64_t, std::micro > square_millimeters
Area with 1 mm² precision.
length< int64_t, std::nano > nanometers
Length with 1 nm precision.
volume< int64_t, std::nano > microliters
Volume with 1 µL (1 mm³) precision.
area< int64_t, std::ratio< 1, 10000 > > square_centimeters
Area with 1 cm² precision.
area< int64_t, std::ratio< 145161, 1562500 > > square_feet
Area with 1 ft² (144 in² = 0.09290304 m²) precision.
volume< int64_t, std::ratio< 2048383, 125000000000 > > cubic_inches
Volume with 1 in³ (16.387064 mL) precision.
microliters cubic_millimeters
Volume with 1 mm³ precision (the same type as microliters).
area< int64_t, std::ratio< 1306449, 1562500 > > square_yards
Area with 1 yd² (9 ft² = 0.83612736 m²) precision.
volume< int64_t, std::ratio< 473176473, 125000000000 > > us_gallons
Volume with 1 US gallon (231 in³ = 3.785411784 L) precision.
volume< int64_t > cubic_meters
Volume with 1 m³ precision.
area< int64_t, std::ratio< 316160658, 78125 > > acres
Area with 1 acre (43,560 ft² = 4046.8564224 m²) precision.
volume< int64_t, std::micro > milliliters
Volume with 1 mL (1 cm³) precision.
area< int64_t, std::ratio< 40468564224, 15625 > > square_miles
Area with 1 mi² (640 acres = 2,589,988.110336 m²) precision.
length< int64_t, std::ratio< 1143, 1250 > > yards
Length with 1 yd (3 ft = 0.9144 m) precision.
volume< int64_t, std::ratio< 55306341, 1953125000 > > cubic_feet
Volume with 1 ft³ (1728 in³ = 28.316846592 L) precision.
volume< int64_t, std::milli > liters
Volume with 1 L (1 dm³) precision.
length< int64_t, std::ratio< 127, 5000 > > inches
Length with 1 in (25.4 mm) precision.
length< int64_t, std::milli > millimeters
Length with 1 mm precision.
length< int64_t, std::kilo > kilometers
Length with 1 km precision.
milliliters cubic_centimeters
Volume with 1 cm³ precision (the same type as milliliters).
area< int64_t > square_meters
Area with 1 m² precision.
quantity< meter_unit, Rep, Precision > length
Length quantity with configurable representation and precision.
quantity< cubic_meter_unit, Rep, Precision > volume
Volume quantity with configurable representation and precision (a ratio of one m³).
area< int64_t, std::ratio< 16129, 25000000 > > square_inches
Area with 1 in² (645.16 mm²) precision.
volume< int64_t, std::ratio< 1493271207, 1953125000 > > cubic_yards
Volume with 1 yd³ (27 ft³ = 0.764554857984 m³) precision.
length< int64_t, std::ratio< 381, 1250 > > feet
Length with 1 ft (12 in = 0.3048 m) precision.
quantity< square_meter_unit, Rep, Precision > area
Area quantity with configurable representation and precision (a ratio of one m²).
length< int64_t, std::micro > micrometers
Length with 1 µm precision.
length< int64_t, std::ratio< 1852 > > nautical_miles
Length with 1 nmi (1852 m) precision.
length< int64_t, std::ratio< 127, 5000000 > > mils
Length with 1 mil (thou, 1/1000 in = 25.4 µm) precision.
length< int64_t > meters
Length with 1 m precision.
area< int64_t, std::ratio< 10000 > > hectares
Area with 1 ha (1 hm² = 10,000 m²) precision.
length< int64_t, std::centi > centimeters
Length with 1 cm precision.
Spatial unit types and utilities.
constexpr bool is_quantity_v
constexpr bool operator==(const quantity< Unit, Rep1, Precision1 > &lhs, const quantity< Unit, Rep2, Precision2 > &rhs)
constexpr ToQuantity trunc(const quantity< Unit, Rep, Precision > &q)
Converts a quantity to the target type, rounding toward zero.
constexpr ToQuantity quantity_cast(const quantity< Unit, Rep, Precision > &q)
Converts a quantity to a different precision or representation.
constexpr ToQuantity ceil(const quantity< Unit, Rep, Precision > &q)
Converts a quantity to the target type, rounding toward positive infinity.
constexpr ToQuantity round(const quantity< Unit, Rep, Precision > &q)
Converts a quantity to the target type, rounding to nearest (ties to even).
constexpr auto operator-(const quantity< Unit, Rep1, Precision1 > &lhs, const quantity< Unit, Rep2, Precision2 > &rhs) -> std::common_type_t< quantity< Unit, Rep1, Precision1 >, quantity< Unit, Rep2, Precision2 > >
Returns the difference of two quantities of the same unit.
std::string to_string(const quantity< Unit, Rep, Precision > &q)
Converts a quantity to a string with its unit suffix.
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 quantity< Unit, Rep, Precision > abs(const quantity< Unit, Rep, Precision > &q)
Returns the absolute value of a quantity.
constexpr power_form_t power_form
Selects the power-form suffix in to_string().
constexpr ToQuantity floor(const quantity< Unit, Rep, Precision > &q)
Converts a quantity to the target type, rounding toward negative 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 auto operator+(const quantity< Unit, Rep1, Precision1 > &lhs, const quantity< Unit, Rep2, Precision2 > &rhs) -> std::common_type_t< quantity< Unit, Rep1, Precision1 >, quantity< Unit, Rep2, Precision2 > >
Returns the sum of two quantities of the same unit.
constexpr auto operator<=>(const quantity< Unit, Rep1, Precision1 > &lhs, const quantity< Unit, Rep2, Precision2 > &rhs)
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.
Tag type selecting the scaled form, see scaled.
Volume, measured in cubic meters.
static constexpr const char * symbol
Trait to detect quantity specializations.
Length, measured in meters.
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.
Area, measured in square meters.
static constexpr const char * symbol
Trait to indicate floating-point-like behavior.
quanta::spatial::quantity< Unit, std::common_type_t< Rep1, Rep2 >, common_precision > type