mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 04:14:27 +02:00
refactor: the rest of the code refactored for new quantity construction way
This commit is contained in:
@@ -336,7 +336,7 @@ public:
|
||||
requires detail::InvokeResultOf<quantity_spec.character, std::plus<>, rep, Value>;
|
||||
}
|
||||
{
|
||||
return ::mp_units::quantity(lhs.number() + rhs);
|
||||
return (lhs.number() + rhs) * R;
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
@@ -347,7 +347,7 @@ public:
|
||||
requires detail::InvokeResultOf<quantity_spec.character, std::plus<>, Value, rep>;
|
||||
}
|
||||
{
|
||||
return ::mp_units::quantity(lhs + rhs.number());
|
||||
return (lhs + rhs.number()) * R;
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
@@ -358,7 +358,7 @@ public:
|
||||
requires detail::InvokeResultOf<quantity_spec.character, std::minus<>, rep, Value>;
|
||||
}
|
||||
{
|
||||
return ::mp_units::quantity(lhs.number() - rhs);
|
||||
return (lhs.number() - rhs) * R;
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
@@ -369,7 +369,7 @@ public:
|
||||
requires detail::InvokeResultOf<quantity_spec.character, std::minus<>, Value, rep>;
|
||||
}
|
||||
{
|
||||
return ::mp_units::quantity(lhs - rhs.number());
|
||||
return (lhs - rhs.number()) * R;
|
||||
}
|
||||
|
||||
template<Representation Value>
|
||||
|
@@ -32,7 +32,6 @@
|
||||
|
||||
|
||||
using namespace mp_units;
|
||||
using namespace mp_units::si::unit_symbols;
|
||||
|
||||
TEST_CASE("uniform_int_distribution")
|
||||
{
|
||||
@@ -53,12 +52,12 @@ TEST_CASE("uniform_int_distribution")
|
||||
constexpr rep b = 5;
|
||||
|
||||
auto stl_dist = std::uniform_int_distribution(a, b);
|
||||
auto units_dist = mp_units::uniform_int_distribution(q(a), q(b));
|
||||
auto units_dist = mp_units::uniform_int_distribution(a * si::metre, b * si::metre);
|
||||
|
||||
CHECK(units_dist.a() == q(stl_dist.a()));
|
||||
CHECK(units_dist.b() == q(stl_dist.b()));
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.a() == stl_dist.a() * si::metre);
|
||||
CHECK(units_dist.b() == stl_dist.b() * si::metre);
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,12 +80,12 @@ TEST_CASE("uniform_real_distribution")
|
||||
constexpr rep b = 5.0;
|
||||
|
||||
auto stl_dist = std::uniform_real_distribution(a, b);
|
||||
auto units_dist = mp_units::uniform_real_distribution(q(a), q(b));
|
||||
auto units_dist = mp_units::uniform_real_distribution(a * si::metre, b * si::metre);
|
||||
|
||||
CHECK(units_dist.a() == q(stl_dist.a()));
|
||||
CHECK(units_dist.b() == q(stl_dist.b()));
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.a() == stl_dist.a() * si::metre);
|
||||
CHECK(units_dist.b() == stl_dist.b() * si::metre);
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,12 +108,12 @@ TEST_CASE("binomial_distribution")
|
||||
constexpr double p = 0.25;
|
||||
|
||||
auto stl_dist = std::binomial_distribution(t, p);
|
||||
auto units_dist = mp_units::binomial_distribution(q(t), p);
|
||||
auto units_dist = mp_units::binomial_distribution(t * si::metre, p);
|
||||
|
||||
CHECK(units_dist.p() == stl_dist.p());
|
||||
CHECK(units_dist.t() == q(stl_dist.t()));
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.t() == stl_dist.t() * si::metre);
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,12 +136,12 @@ TEST_CASE("negative_binomial_distribution")
|
||||
constexpr double p = 0.25;
|
||||
|
||||
auto stl_dist = std::negative_binomial_distribution(k, p);
|
||||
auto units_dist = mp_units::negative_binomial_distribution(q(k), p);
|
||||
auto units_dist = mp_units::negative_binomial_distribution(k * si::metre, p);
|
||||
|
||||
CHECK(units_dist.p() == stl_dist.p());
|
||||
CHECK(units_dist.k() == q(stl_dist.k()));
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.k() == stl_dist.k() * si::metre);
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,8 +165,8 @@ TEST_CASE("geometric_distribution")
|
||||
auto units_dist = mp_units::geometric_distribution<q>(p);
|
||||
|
||||
CHECK(units_dist.p() == stl_dist.p());
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,8 +190,8 @@ TEST_CASE("poisson_distribution")
|
||||
auto units_dist = mp_units::poisson_distribution<q>(mean);
|
||||
|
||||
CHECK(units_dist.mean() == stl_dist.mean());
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,8 +215,8 @@ TEST_CASE("exponential_distribution")
|
||||
auto units_dist = mp_units::exponential_distribution<q>(lambda);
|
||||
|
||||
CHECK(units_dist.lambda() == stl_dist.lambda());
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,8 +243,8 @@ TEST_CASE("gamma_distribution")
|
||||
|
||||
CHECK(units_dist.alpha() == stl_dist.alpha());
|
||||
CHECK(units_dist.beta() == stl_dist.beta());
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,8 +271,8 @@ TEST_CASE("weibull_distribution")
|
||||
|
||||
CHECK(units_dist.a() == stl_dist.a());
|
||||
CHECK(units_dist.b() == stl_dist.b());
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,12 +295,12 @@ TEST_CASE("extreme_value_distribution")
|
||||
constexpr rep b = 2.0;
|
||||
|
||||
auto stl_dist = std::extreme_value_distribution(a, b);
|
||||
auto units_dist = mp_units::extreme_value_distribution<q>(q(a), b);
|
||||
auto units_dist = mp_units::extreme_value_distribution<q>(a * si::metre, b);
|
||||
|
||||
CHECK(units_dist.a() == q(stl_dist.a()));
|
||||
CHECK(units_dist.a() == stl_dist.a() * si::metre);
|
||||
CHECK(units_dist.b() == stl_dist.b());
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,12 +323,12 @@ TEST_CASE("normal_distribution")
|
||||
constexpr rep stddev = 2.0;
|
||||
|
||||
auto stl_dist = std::normal_distribution(mean, stddev);
|
||||
auto units_dist = mp_units::normal_distribution(q(mean), q(stddev));
|
||||
auto units_dist = mp_units::normal_distribution(mean * si::metre, stddev * si::metre);
|
||||
|
||||
CHECK(units_dist.mean() == q(stl_dist.mean()));
|
||||
CHECK(units_dist.stddev() == q(stl_dist.stddev()));
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.mean() == stl_dist.mean() * si::metre);
|
||||
CHECK(units_dist.stddev() == stl_dist.stddev() * si::metre);
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,12 +351,12 @@ TEST_CASE("lognormal_distribution")
|
||||
constexpr rep s = 2.0;
|
||||
|
||||
auto stl_dist = std::lognormal_distribution(m, s);
|
||||
auto units_dist = mp_units::lognormal_distribution(q(m), q(s));
|
||||
auto units_dist = mp_units::lognormal_distribution(m * si::metre, s * si::metre);
|
||||
|
||||
CHECK(units_dist.m() == q(stl_dist.m()));
|
||||
CHECK(units_dist.s() == q(stl_dist.s()));
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.m() == stl_dist.m() * si::metre);
|
||||
CHECK(units_dist.s() == stl_dist.s() * si::metre);
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,8 +380,8 @@ TEST_CASE("chi_squared_distribution")
|
||||
auto units_dist = mp_units::chi_squared_distribution<q>(n);
|
||||
|
||||
CHECK(units_dist.n() == stl_dist.n());
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,12 +404,12 @@ TEST_CASE("cauchy_distribution")
|
||||
constexpr rep b = 2.0;
|
||||
|
||||
auto stl_dist = std::cauchy_distribution(a, b);
|
||||
auto units_dist = mp_units::cauchy_distribution(q(a), q(b));
|
||||
auto units_dist = mp_units::cauchy_distribution(a * si::metre, b * si::metre);
|
||||
|
||||
CHECK(units_dist.a() == q(stl_dist.a()));
|
||||
CHECK(units_dist.b() == q(stl_dist.b()));
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.a() == stl_dist.a() * si::metre);
|
||||
CHECK(units_dist.b() == stl_dist.b() * si::metre);
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,8 +436,8 @@ TEST_CASE("fisher_f_distribution")
|
||||
|
||||
CHECK(units_dist.m() == stl_dist.m());
|
||||
CHECK(units_dist.n() == stl_dist.n());
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,8 +461,8 @@ TEST_CASE("student_t_distribution")
|
||||
auto units_dist = mp_units::student_t_distribution<q>(n);
|
||||
|
||||
CHECK(units_dist.n() == stl_dist.n());
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,8 +476,8 @@ TEST_CASE("discrete_distribution")
|
||||
auto stl_dist = std::discrete_distribution<rep>();
|
||||
auto units_dist = mp_units::discrete_distribution<q>();
|
||||
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
CHECK(units_dist.probabilities() == stl_dist.probabilities());
|
||||
}
|
||||
|
||||
@@ -528,8 +527,8 @@ TEST_CASE("piecewise_constant_distribution")
|
||||
auto stl_dist = std::piecewise_constant_distribution<rep>();
|
||||
auto units_dist = mp_units::piecewise_constant_distribution<q>();
|
||||
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
CHECK(stl_dist.intervals().size() == 2);
|
||||
CHECK(units_dist.intervals().size() == 2);
|
||||
CHECK(stl_dist.densities().size() == 1);
|
||||
@@ -595,8 +594,8 @@ TEST_CASE("piecewise_linear_distribution")
|
||||
auto stl_dist = std::piecewise_linear_distribution<rep>();
|
||||
auto units_dist = mp_units::piecewise_linear_distribution<q>();
|
||||
|
||||
CHECK(units_dist.min() == q(stl_dist.min()));
|
||||
CHECK(units_dist.max() == q(stl_dist.max()));
|
||||
CHECK(units_dist.min() == stl_dist.min() * si::metre);
|
||||
CHECK(units_dist.max() == stl_dist.max() * si::metre);
|
||||
CHECK(stl_dist.intervals().size() == 2);
|
||||
CHECK(units_dist.intervals().size() == 2);
|
||||
CHECK(stl_dist.densities().size() == 2);
|
||||
|
@@ -85,7 +85,7 @@ template<typename T, typename U>
|
||||
template<Quantity Q1, Quantity Q2>
|
||||
requires is_vector<typename Q1::rep> && is_vector<typename Q2::rep> &&
|
||||
requires(typename Q1::rep v1, typename Q2::rep v2) { cross_product(v1, v2); }
|
||||
[[nodiscard]] quantity_of<Q1::reference * Q2::reference> auto cross_product(const Q1& q1, const Q2& q2)
|
||||
[[nodiscard]] QuantityOf<Q1::reference * Q2::reference> auto cross_product(const Q1& q1, const Q2& q2)
|
||||
{
|
||||
return (Q1::reference * Q2::reference)(cross_product(q1.number(), q2.number()));
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <mp_units/quantity.h>
|
||||
#include <mp_units/reference.h>
|
||||
#include <mp_units/systems/iec80000/iec80000.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
|
||||
@@ -73,28 +75,28 @@ static_assert(verify(decision_content, scalar, one));
|
||||
|
||||
|
||||
// unit conversions
|
||||
static_assert(storage_capacity[B](1) == storage_capacity[bit](8));
|
||||
static_assert(storage_capacity[bit](1024) == storage_capacity[Kibit](1));
|
||||
static_assert(storage_capacity[B](1024) == storage_capacity[KiB](1));
|
||||
static_assert(storage_capacity[bit](8 * 1024) == storage_capacity[KiB](1));
|
||||
static_assert(storage_capacity[Kibit](8) == storage_capacity[KiB](1));
|
||||
static_assert(storage_capacity(1 * B) == storage_capacity(8 * bit));
|
||||
static_assert(storage_capacity(1024 * bit) == storage_capacity(1 * Kibit));
|
||||
static_assert(storage_capacity(1024 * B) == storage_capacity(1 * KiB));
|
||||
static_assert(storage_capacity(8 * 1024 * bit) == storage_capacity(1 * KiB));
|
||||
static_assert(storage_capacity(8 * Kibit) == storage_capacity(1 * KiB));
|
||||
|
||||
static_assert(storage_capacity[kbit](1) == storage_capacity[bit](1000));
|
||||
static_assert(storage_capacity[Mibit](2000) == storage_capacity[kbit](2097152));
|
||||
static_assert(storage_capacity(1 * kbit) == storage_capacity(1000 * bit));
|
||||
static_assert(storage_capacity(2000 * Mibit) == storage_capacity(2097152 * kbit));
|
||||
|
||||
static_assert(storage_capacity[Kibit](1) == storage_capacity[bit](1024));
|
||||
static_assert(storage_capacity[Mibit](1) == storage_capacity[Kibit](1024));
|
||||
static_assert(storage_capacity[Gibit](1) == storage_capacity[Mibit](1024));
|
||||
static_assert(storage_capacity[Tibit](1) == storage_capacity[Gibit](1024));
|
||||
static_assert(storage_capacity[Pibit](1) == storage_capacity[Tibit](1024));
|
||||
static_assert(storage_capacity[Eibit](1) == storage_capacity[Pibit](1024));
|
||||
static_assert(storage_capacity(1 * Kibit) == storage_capacity(1024 * bit));
|
||||
static_assert(storage_capacity(1 * Mibit) == storage_capacity(1024 * Kibit));
|
||||
static_assert(storage_capacity(1 * Gibit) == storage_capacity(1024 * Mibit));
|
||||
static_assert(storage_capacity(1 * Tibit) == storage_capacity(1024 * Gibit));
|
||||
static_assert(storage_capacity(1 * Pibit) == storage_capacity(1024 * Tibit));
|
||||
static_assert(storage_capacity(1 * Eibit) == storage_capacity(1024 * Pibit));
|
||||
|
||||
// transfer rate
|
||||
static_assert(storage_capacity[B](16) / isq::duration[s](2) == transfer_rate[B / s](8));
|
||||
static_assert(storage_capacity[kB](120) / isq::duration[min](2) == transfer_rate[B / s](1000));
|
||||
static_assert(storage_capacity(16 * B) / isq::duration(2 * s) == transfer_rate(8 * (B / s)));
|
||||
static_assert(storage_capacity(120 * kB) / isq::duration(2 * min) == transfer_rate(1000 * (B / s)));
|
||||
|
||||
// modulation rate
|
||||
static_assert(12 / isq::duration[s](2) == modulation_rate[Bd](6));
|
||||
static_assert(6000 / isq::duration[s](3) == modulation_rate[kBd](2));
|
||||
static_assert(12 / isq::duration(2 * s) == modulation_rate(6 * Bd));
|
||||
static_assert(6000 / isq::duration(3 * s) == modulation_rate(2 * kBd));
|
||||
|
||||
} // namespace
|
||||
|
@@ -35,46 +35,46 @@ using namespace mp_units::imperial::unit_symbols;
|
||||
// https://en.wikipedia.org/wiki/United_States_customary_units#Length
|
||||
|
||||
// International
|
||||
static_assert(isq::length[twip](17'280) == isq::length[ft](1));
|
||||
static_assert(isq::length[th](12'000) == isq::length[ft](1));
|
||||
static_assert(isq::length[Bc](3) == isq::length[th](1'000));
|
||||
static_assert(isq::length[in](1) == isq::length[Bc](3));
|
||||
static_assert(isq::length[hh](1) == isq::length[in](4));
|
||||
static_assert(isq::length[ft](1) == isq::length[hh](3));
|
||||
static_assert(isq::length[yd](1) == isq::length[ft](3));
|
||||
static_assert(isq::length[ch](1) == isq::length[yd](22));
|
||||
static_assert(isq::length[fur](1) == isq::length[ch](10));
|
||||
static_assert(isq::length[mi](1) == isq::length[fur](8));
|
||||
static_assert(isq::length[le](1) == isq::length[mi](3));
|
||||
static_assert(17'280 * isq::length[twip] == 1 * isq::length[ft]);
|
||||
static_assert(12'000 * isq::length[th] == 1 * isq::length[ft]);
|
||||
static_assert(3 * isq::length[Bc] == 1'000 * isq::length[th]);
|
||||
static_assert(1 * isq::length[in] == 3 * isq::length[Bc]);
|
||||
static_assert(1 * isq::length[hh] == 4 * isq::length[in]);
|
||||
static_assert(1 * isq::length[ft] == 3 * isq::length[hh]);
|
||||
static_assert(1 * isq::length[yd] == 3 * isq::length[ft]);
|
||||
static_assert(1 * isq::length[ch] == 22 * isq::length[yd]);
|
||||
static_assert(1 * isq::length[fur] == 10 * isq::length[ch]);
|
||||
static_assert(1 * isq::length[mi] == 8 * isq::length[fur]);
|
||||
static_assert(1 * isq::length[le] == 3 * isq::length[mi]);
|
||||
|
||||
// International Nautical
|
||||
static_assert(isq::length[cb](1) == isq::length[ftm](100));
|
||||
static_assert(isq::length[nmi](1) == isq::length[cb](10));
|
||||
static_assert(1 * isq::length[cb] == 100 * isq::length[ftm]));
|
||||
static_assert(1 * isq::length[nmi] == 10 * isq::length[cb]));
|
||||
|
||||
// survey
|
||||
static_assert(isq::length[li](100) == isq::length[ch](1));
|
||||
static_assert(isq::length[rd](1) == isq::length[li](25));
|
||||
static_assert(100 * isq::length[li] == 1 * isq::length[ch]);
|
||||
static_assert(1 * isq::length[rd] == 25 * isq::length[li]);
|
||||
|
||||
// Area
|
||||
static_assert(isq::area[perch](1) == isq::length[rd](1) * isq::length[rd](1));
|
||||
static_assert(isq::area[rood](1) == isq::length[fur](1) * isq::length[rd](1));
|
||||
static_assert(isq::area[acre](1) == isq::length[fur](1) * isq::length[ch](1));
|
||||
static_assert(1 * isq::area[perch] == 1 * isq::length[rd] * (1 * isq::length[rd]));
|
||||
static_assert(1 * isq::area[rood] == 1 * isq::length[fur] * (1 * isq::length[rd]));
|
||||
static_assert(1 * isq::area[acre] == 1 * isq::length[fur] * (1 * isq::length[ch]));
|
||||
|
||||
// Volume
|
||||
static_assert(isq::volume[fl_oz](20) == isq::volume[pt](1));
|
||||
static_assert(isq::volume[gi](1) == isq::volume[fl_oz](5));
|
||||
static_assert(isq::volume[pt](1) == isq::volume[fl_oz](20));
|
||||
static_assert(isq::volume[qt](1) == isq::volume[pt](2));
|
||||
static_assert(isq::volume[gal](1) == isq::volume[pt](8));
|
||||
static_assert(20 * isq::volume[fl_oz] == 1 * isq::volume[pt]);
|
||||
static_assert(1 * isq::volume[gi] == 5 * isq::volume[fl_oz]);
|
||||
static_assert(1 * isq::volume[pt] == 20 * isq::volume[fl_oz]);
|
||||
static_assert(1 * isq::volume[qt] == 2 * isq::volume[pt]);
|
||||
static_assert(1 * isq::volume[gal] == 8 * isq::volume[pt]);
|
||||
|
||||
// Mass
|
||||
static_assert(isq::mass[gr](7'000) == isq::mass[lb](1));
|
||||
static_assert(isq::mass[dr](256) == isq::mass[lb](1));
|
||||
static_assert(isq::mass[oz](1) == isq::mass[dr](16));
|
||||
static_assert(isq::mass[lb](1) == isq::mass[oz](16));
|
||||
static_assert(isq::mass[st](1) == isq::mass[lb](14));
|
||||
static_assert(isq::mass[qr](1) == isq::mass[st](2));
|
||||
static_assert(isq::mass[cwt](1) == isq::mass[lb](112));
|
||||
static_assert(isq::mass[t](1) == isq::mass[cwt](20));
|
||||
static_assert(7'000 * isq::mass[gr] == 1 * isq::mass[lb]);
|
||||
static_assert(256 * isq::mass[dr] == 1 * isq::mass[lb]);
|
||||
static_assert(1 * isq::mass[oz] == 16 * isq::mass[dr]);
|
||||
static_assert(1 * isq::mass[lb] == 16 * isq::mass[oz]);
|
||||
static_assert(1 * isq::mass[st] == 14 * isq::mass[lb]);
|
||||
static_assert(1 * isq::mass[qr] == 2 * isq::mass[st]);
|
||||
static_assert(1 * isq::mass[cwt] == 112 * isq::mass[lb]);
|
||||
static_assert(1 * isq::mass[t] == 20 * isq::mass[cwt]);
|
||||
|
||||
} // namespace
|
||||
|
@@ -20,6 +20,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include <mp_units/reference.h>
|
||||
#include <mp_units/systems/isq/isq.h>
|
||||
#include <mp_units/systems/si/unit_symbols.h>
|
||||
|
||||
|
Reference in New Issue
Block a user