mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
feat: quantity_ref_from
disallowed for rvalues
This commit is contained in:
@@ -146,34 +146,20 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// data access
|
// data access
|
||||||
#ifdef __cpp_explicit_this_parameter
|
|
||||||
template<typename Self, std::same_as<std::remove_const_t<decltype(PO)>> PO2>
|
|
||||||
[[nodiscard]] constexpr auto&& quantity_ref_from(this Self&& self, PO2) noexcept
|
|
||||||
{
|
|
||||||
return std::forward<Self>(self).quantity_from_origin_;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
template<std::same_as<std::remove_const_t<decltype(PO)>> PO2>
|
template<std::same_as<std::remove_const_t<decltype(PO)>> PO2>
|
||||||
[[nodiscard]] constexpr quantity_type& quantity_ref_from(PO2) & noexcept
|
[[nodiscard]] constexpr quantity_type& quantity_ref_from(PO2) & noexcept
|
||||||
{
|
{
|
||||||
return quantity_from_origin_;
|
return quantity_from_origin_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<std::same_as<std::remove_const_t<decltype(PO)>> PO2>
|
template<std::same_as<std::remove_const_t<decltype(PO)>> PO2>
|
||||||
[[nodiscard]] constexpr const quantity_type& quantity_ref_from(PO2) const& noexcept
|
[[nodiscard]] constexpr const quantity_type& quantity_ref_from(PO2) const& noexcept
|
||||||
{
|
{
|
||||||
return quantity_from_origin_;
|
return quantity_from_origin_;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<std::same_as<std::remove_const_t<decltype(PO)>> PO2>
|
template<std::same_as<std::remove_const_t<decltype(PO)>> PO2>
|
||||||
[[nodiscard]] constexpr quantity_type&& quantity_ref_from(PO2) && noexcept
|
constexpr const quantity_type&& quantity_ref_from(PO2) const&& noexcept = delete;
|
||||||
{
|
|
||||||
return std::move(quantity_from_origin_);
|
|
||||||
}
|
|
||||||
template<std::same_as<std::remove_const_t<decltype(PO)>> PO2>
|
|
||||||
[[nodiscard]] constexpr const quantity_type&& quantity_ref_from(PO2) const&& noexcept
|
|
||||||
{
|
|
||||||
return std::move(quantity_from_origin_);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<PointOrigin PO2>
|
template<PointOrigin PO2>
|
||||||
requires requires { quantity_point{} - PO2{}; }
|
requires requires { quantity_point{} - PO2{}; }
|
||||||
|
@@ -241,23 +241,18 @@ static_assert(
|
|||||||
// static member functions
|
// static member functions
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
|
|
||||||
static_assert(
|
static_assert(quantity_point<isq::height[m], mean_sea_level>::zero().quantity_from_origin_.numerical_value_ == 0);
|
||||||
quantity_point<isq::height[m], mean_sea_level>::zero().quantity_ref_from(mean_sea_level).numerical_value_ == 0);
|
static_assert(quantity_point<isq::height[m], mean_sea_level>::min().quantity_from_origin_.numerical_value_ ==
|
||||||
static_assert(
|
|
||||||
quantity_point<isq::height[m], mean_sea_level>::min().quantity_ref_from(mean_sea_level).numerical_value_ ==
|
|
||||||
std::numeric_limits<double>::lowest());
|
std::numeric_limits<double>::lowest());
|
||||||
static_assert(
|
static_assert(quantity_point<isq::height[m], mean_sea_level>::max().quantity_from_origin_.numerical_value_ ==
|
||||||
quantity_point<isq::height[m], mean_sea_level>::max().quantity_ref_from(mean_sea_level).numerical_value_ ==
|
|
||||||
std::numeric_limits<double>::max());
|
std::numeric_limits<double>::max());
|
||||||
|
|
||||||
static_assert(
|
static_assert(
|
||||||
|
|
||||||
quantity_point<isq::height[m], ground_level, int>::zero().quantity_ref_from(ground_level).numerical_value_ == 0);
|
quantity_point<isq::height[m], ground_level, int>::zero().quantity_from_origin_.numerical_value_ == 0);
|
||||||
static_assert(
|
static_assert(quantity_point<isq::height[m], ground_level, int>::min().quantity_from_origin_.numerical_value_ ==
|
||||||
quantity_point<isq::height[m], ground_level, int>::min().quantity_ref_from(ground_level).numerical_value_ ==
|
|
||||||
std::numeric_limits<int>::lowest());
|
std::numeric_limits<int>::lowest());
|
||||||
static_assert(
|
static_assert(quantity_point<isq::height[m], ground_level, int>::max().quantity_from_origin_.numerical_value_ ==
|
||||||
quantity_point<isq::height[m], ground_level, int>::max().quantity_ref_from(ground_level).numerical_value_ ==
|
|
||||||
std::numeric_limits<int>::max());
|
std::numeric_limits<int>::max());
|
||||||
|
|
||||||
|
|
||||||
@@ -544,42 +539,36 @@ static_assert(
|
|||||||
// obtaining a relative quantity
|
// obtaining a relative quantity
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
|
|
||||||
static_assert((mean_sea_level + 42 * m).quantity_ref_from(mean_sea_level) == 42 * m);
|
static_assert((mean_sea_level + 42 * m).quantity_from_origin_ == 42 * m);
|
||||||
static_assert((mean_sea_level + isq::height(42 * m)).quantity_ref_from(mean_sea_level) == 42 * m);
|
static_assert((mean_sea_level + isq::height(42 * m)).quantity_from_origin_ == 42 * m);
|
||||||
|
|
||||||
static_assert((zero + 1 * one).quantity_ref_from(zero) == 1 * one);
|
static_assert((zero + 1 * one).quantity_from_origin_ == 1 * one);
|
||||||
static_assert((zero + dimensionless(1 * one)).quantity_ref_from(zero) == 1 * one);
|
static_assert((zero + dimensionless(1 * one)).quantity_from_origin_ == 1 * one);
|
||||||
|
|
||||||
static_assert((mean_sea_level + 42 * m).quantity_ref_from(mean_sea_level) == 42 * m);
|
static_assert((mean_sea_level + 42 * m).quantity_from_origin_ == 42 * m);
|
||||||
static_assert((ground_level + 42 * m).quantity_ref_from(ground_level) == 42 * m);
|
static_assert((ground_level + 42 * m).quantity_from_origin_ == 42 * m);
|
||||||
static_assert((tower_peak + 42 * m).quantity_ref_from(tower_peak) == 42 * m);
|
static_assert((tower_peak + 42 * m).quantity_from_origin_ == 42 * m);
|
||||||
|
|
||||||
static_assert(quantity_point<isq::height[m], mean_sea_level>(ground_level + 42 * m).quantity_ref_from(mean_sea_level) ==
|
static_assert(quantity_point<isq::height[m], mean_sea_level>(ground_level + 42 * m).quantity_from_origin_ == 84 * m);
|
||||||
84 * m);
|
static_assert(quantity_point<isq::height[m], mean_sea_level>(tower_peak + 42 * m).quantity_from_origin_ == 126 * m);
|
||||||
static_assert(quantity_point<isq::height[m], mean_sea_level>(tower_peak + 42 * m).quantity_ref_from(mean_sea_level) ==
|
|
||||||
126 * m);
|
|
||||||
|
|
||||||
static_assert(quantity_point<isq::height[m], ground_level>(mean_sea_level + 84 * m).quantity_ref_from(ground_level) ==
|
static_assert(quantity_point<isq::height[m], ground_level>(mean_sea_level + 84 * m).quantity_from_origin_ == 42 * m);
|
||||||
42 * m);
|
static_assert(quantity_point<isq::height[m], ground_level>(tower_peak + 42 * m).quantity_from_origin_ == 84 * m);
|
||||||
static_assert(quantity_point<isq::height[m], ground_level>(tower_peak + 42 * m).quantity_ref_from(ground_level) ==
|
|
||||||
84 * m);
|
|
||||||
|
|
||||||
static_assert(quantity_point<isq::height[m], tower_peak>(mean_sea_level + 42 * m).quantity_ref_from(tower_peak) ==
|
static_assert(quantity_point<isq::height[m], tower_peak>(mean_sea_level + 42 * m).quantity_from_origin_ == -42 * m);
|
||||||
-42 * m);
|
static_assert(quantity_point<isq::height[m], tower_peak>(ground_level + 84 * m).quantity_from_origin_ == 42 * m);
|
||||||
static_assert(quantity_point<isq::height[m], tower_peak>(ground_level + 84 * m).quantity_ref_from(tower_peak) ==
|
|
||||||
42 * m);
|
|
||||||
|
|
||||||
static_assert((mean_sea_level + 42 * m).point_for(mean_sea_level).quantity_ref_from(mean_sea_level) == 42 * m);
|
static_assert((mean_sea_level + 42 * m).point_for(mean_sea_level).quantity_from_origin_ == 42 * m);
|
||||||
static_assert((ground_level + 42 * m).point_for(mean_sea_level).quantity_ref_from(mean_sea_level) == 84 * m);
|
static_assert((ground_level + 42 * m).point_for(mean_sea_level).quantity_from_origin_ == 84 * m);
|
||||||
static_assert((tower_peak + 42 * m).point_for(mean_sea_level).quantity_ref_from(mean_sea_level) == 126 * m);
|
static_assert((tower_peak + 42 * m).point_for(mean_sea_level).quantity_from_origin_ == 126 * m);
|
||||||
|
|
||||||
static_assert((ground_level + 84 * m).point_for(ground_level).quantity_ref_from(ground_level) == 84 * m);
|
static_assert((ground_level + 84 * m).point_for(ground_level).quantity_from_origin_ == 84 * m);
|
||||||
static_assert((mean_sea_level + 84 * m).point_for(ground_level).quantity_ref_from(ground_level) == 42 * m);
|
static_assert((mean_sea_level + 84 * m).point_for(ground_level).quantity_from_origin_ == 42 * m);
|
||||||
static_assert((tower_peak + 42 * m).point_for(ground_level).quantity_ref_from(ground_level) == 84 * m);
|
static_assert((tower_peak + 42 * m).point_for(ground_level).quantity_from_origin_ == 84 * m);
|
||||||
|
|
||||||
static_assert((tower_peak + 42 * m).point_for(tower_peak).quantity_ref_from(tower_peak) == 42 * m);
|
static_assert((tower_peak + 42 * m).point_for(tower_peak).quantity_from_origin_ == 42 * m);
|
||||||
static_assert((mean_sea_level + 42 * m).point_for(tower_peak).quantity_ref_from(tower_peak) == -42 * m);
|
static_assert((mean_sea_level + 42 * m).point_for(tower_peak).quantity_from_origin_ == -42 * m);
|
||||||
static_assert((ground_level + 84 * m).point_for(tower_peak).quantity_ref_from(tower_peak) == 42 * m);
|
static_assert((ground_level + 84 * m).point_for(tower_peak).quantity_from_origin_ == 42 * m);
|
||||||
|
|
||||||
static_assert(is_of_type<(ground_level + isq::height(short(42) * m)).point_for(mean_sea_level),
|
static_assert(is_of_type<(ground_level + isq::height(short(42) * m)).point_for(mean_sea_level),
|
||||||
quantity_point<isq::height[m], mean_sea_level, int>>);
|
quantity_point<isq::height[m], mean_sea_level, int>>);
|
||||||
@@ -589,15 +578,15 @@ static_assert(is_of_type<(ground_level + isq::height(short(42) * m)).point_for(m
|
|||||||
// converting to a different unit
|
// converting to a different unit
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
|
||||||
static_assert((mean_sea_level + 2. * km).in(km).quantity_ref_from(mean_sea_level).numerical_value_ == 2.);
|
static_assert((mean_sea_level + 2. * km).in(km).quantity_from_origin_.numerical_value_ == 2.);
|
||||||
static_assert((mean_sea_level + 2. * km).in(m).quantity_ref_from(mean_sea_level).numerical_value_ == 2000.);
|
static_assert((mean_sea_level + 2. * km).in(m).quantity_from_origin_.numerical_value_ == 2000.);
|
||||||
static_assert((mean_sea_level + 2000. * m).in(km).quantity_ref_from(mean_sea_level).numerical_value_ == 2.);
|
static_assert((mean_sea_level + 2000. * m).in(km).quantity_from_origin_.numerical_value_ == 2.);
|
||||||
static_assert((ground_level + 2. * km).in(km).quantity_ref_from(ground_level).numerical_value_ == 2.);
|
static_assert((ground_level + 2. * km).in(km).quantity_from_origin_.numerical_value_ == 2.);
|
||||||
static_assert((ground_level + 2. * km).in(m).quantity_ref_from(ground_level).numerical_value_ == 2000.);
|
static_assert((ground_level + 2. * km).in(m).quantity_from_origin_.numerical_value_ == 2000.);
|
||||||
static_assert((ground_level + 2000. * m).in(km).quantity_ref_from(ground_level).numerical_value_ == 2.);
|
static_assert((ground_level + 2000. * m).in(km).quantity_from_origin_.numerical_value_ == 2.);
|
||||||
static_assert((tower_peak + 2. * km).in(km).quantity_ref_from(tower_peak).numerical_value_ == 2.);
|
static_assert((tower_peak + 2. * km).in(km).quantity_from_origin_.numerical_value_ == 2.);
|
||||||
static_assert((tower_peak + 2. * km).in(m).quantity_ref_from(tower_peak).numerical_value_ == 2000.);
|
static_assert((tower_peak + 2. * km).in(m).quantity_from_origin_.numerical_value_ == 2000.);
|
||||||
static_assert((tower_peak + 2000. * m).in(km).quantity_ref_from(tower_peak).numerical_value_ == 2.);
|
static_assert((tower_peak + 2000. * m).in(km).quantity_from_origin_.numerical_value_ == 2.);
|
||||||
|
|
||||||
#if MP_UNITS_COMP_GCC != 10 || MP_UNITS_COMP_GCC_MINOR > 2
|
#if MP_UNITS_COMP_GCC != 10 || MP_UNITS_COMP_GCC_MINOR > 2
|
||||||
template<template<auto, auto, typename> typename QP>
|
template<template<auto, auto, typename> typename QP>
|
||||||
@@ -629,18 +618,18 @@ static_assert(([]() {
|
|||||||
quantity_point l1{mean_sea_level + 1 * m}, l2{mean_sea_level + 2 * m};
|
quantity_point l1{mean_sea_level + 1 * m}, l2{mean_sea_level + 2 * m};
|
||||||
return l2 = l1;
|
return l2 = l1;
|
||||||
}())
|
}())
|
||||||
.quantity_ref_from(mean_sea_level) == 1 * m);
|
.quantity_from_origin_ == 1 * m);
|
||||||
static_assert(([]() {
|
static_assert(([]() {
|
||||||
const quantity_point l1{mean_sea_level + 1 * m};
|
const quantity_point l1{mean_sea_level + 1 * m};
|
||||||
quantity_point l2{mean_sea_level + 2 * m};
|
quantity_point l2{mean_sea_level + 2 * m};
|
||||||
return l2 = l1;
|
return l2 = l1;
|
||||||
}())
|
}())
|
||||||
.quantity_ref_from(mean_sea_level) == 1 * m);
|
.quantity_from_origin_ == 1 * m);
|
||||||
static_assert(([]() {
|
static_assert(([]() {
|
||||||
quantity_point l1{mean_sea_level + 1 * m}, l2{mean_sea_level + 2 * m};
|
quantity_point l1{mean_sea_level + 1 * m}, l2{mean_sea_level + 2 * m};
|
||||||
return l2 = std::move(l1);
|
return l2 = std::move(l1);
|
||||||
}())
|
}())
|
||||||
.quantity_ref_from(mean_sea_level) == 1 * m);
|
.quantity_from_origin_ == 1 * m);
|
||||||
|
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
@@ -670,14 +659,14 @@ static_assert([](auto v) {
|
|||||||
////////////////////////
|
////////////////////////
|
||||||
|
|
||||||
// same type
|
// same type
|
||||||
static_assert((mean_sea_level + 1 * m += 1 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 2);
|
static_assert((mean_sea_level + 1 * m += 1 * m).quantity_from_origin_.numerical_value_ == 2);
|
||||||
static_assert((mean_sea_level + 2 * m -= 1 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 1);
|
static_assert((mean_sea_level + 2 * m -= 1 * m).quantity_from_origin_.numerical_value_ == 1);
|
||||||
|
|
||||||
// different types
|
// different types
|
||||||
static_assert((mean_sea_level + 2.5 * m += 3 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 5.5);
|
static_assert((mean_sea_level + 2.5 * m += 3 * m).quantity_from_origin_.numerical_value_ == 5.5);
|
||||||
static_assert((mean_sea_level + 123 * m += 1 * km).quantity_ref_from(mean_sea_level).numerical_value_ == 1123);
|
static_assert((mean_sea_level + 123 * m += 1 * km).quantity_from_origin_.numerical_value_ == 1123);
|
||||||
static_assert((mean_sea_level + 5.5 * m -= 3 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 2.5);
|
static_assert((mean_sea_level + 5.5 * m -= 3 * m).quantity_from_origin_.numerical_value_ == 2.5);
|
||||||
static_assert((mean_sea_level + 1123 * m -= 1 * km).quantity_ref_from(mean_sea_level).numerical_value_ == 123);
|
static_assert((mean_sea_level + 1123 * m -= 1 * km).quantity_from_origin_.numerical_value_ == 123);
|
||||||
|
|
||||||
|
|
||||||
template<template<auto, auto, typename> typename QP>
|
template<template<auto, auto, typename> typename QP>
|
||||||
@@ -949,28 +938,22 @@ static_assert(is_of_type<(1 * m + tower_peak) - (1 * m + other_ground_level), qu
|
|||||||
|
|
||||||
// check for integral types promotion
|
// check for integral types promotion
|
||||||
static_assert(is_same_v<decltype(((mean_sea_level + std::uint8_t(0) * m) + std::uint8_t(0) * m)
|
static_assert(is_same_v<decltype(((mean_sea_level + std::uint8_t(0) * m) + std::uint8_t(0) * m)
|
||||||
.quantity_ref_from(mean_sea_level)
|
.quantity_from_origin_.numerical_value_),
|
||||||
.numerical_value_),
|
|
||||||
int>);
|
int>);
|
||||||
static_assert(is_same_v<decltype((std::uint8_t(0) * m + (mean_sea_level + std::uint8_t(0) * m))
|
static_assert(is_same_v<decltype((std::uint8_t(0) * m + (mean_sea_level + std::uint8_t(0) * m))
|
||||||
.quantity_ref_from(mean_sea_level)
|
.quantity_from_origin_.numerical_value_),
|
||||||
.numerical_value_),
|
|
||||||
int>);
|
int>);
|
||||||
static_assert(is_same_v<decltype(((mean_sea_level + std::uint8_t(0) * m) - std::uint8_t(0) * m)
|
static_assert(is_same_v<decltype(((mean_sea_level + std::uint8_t(0) * m) - std::uint8_t(0) * m)
|
||||||
.quantity_ref_from(mean_sea_level)
|
.quantity_from_origin_.numerical_value_),
|
||||||
.numerical_value_),
|
|
||||||
int>);
|
int>);
|
||||||
static_assert(
|
static_assert(
|
||||||
is_same_v<
|
is_same_v<
|
||||||
decltype(((mean_sea_level + std::uint8_t(0) * m) - (mean_sea_level + std::uint8_t(0) * m)).numerical_value_), int>);
|
decltype(((mean_sea_level + std::uint8_t(0) * m) - (mean_sea_level + std::uint8_t(0) * m)).numerical_value_), int>);
|
||||||
static_assert(((mean_sea_level + std::uint8_t(128) * m) + std::uint8_t(128) * m)
|
static_assert(((mean_sea_level + std::uint8_t(128) * m) + std::uint8_t(128) * m)
|
||||||
.quantity_ref_from(mean_sea_level)
|
.quantity_from_origin_.numerical_value_ == std::uint8_t(128) + std::uint8_t(128));
|
||||||
.numerical_value_ == std::uint8_t(128) + std::uint8_t(128));
|
|
||||||
static_assert((std::uint8_t(128) * m + (mean_sea_level + std::uint8_t(128) * m))
|
static_assert((std::uint8_t(128) * m + (mean_sea_level + std::uint8_t(128) * m))
|
||||||
.quantity_ref_from(mean_sea_level)
|
.quantity_from_origin_.numerical_value_ == std::uint8_t(128) + std::uint8_t(128));
|
||||||
.numerical_value_ == std::uint8_t(128) + std::uint8_t(128));
|
static_assert(((mean_sea_level + std::uint8_t(0) * m) - std::uint8_t(1) * m).quantity_from_origin_.numerical_value_ ==
|
||||||
static_assert(
|
|
||||||
((mean_sea_level + std::uint8_t(0) * m) - std::uint8_t(1) * m).quantity_ref_from(mean_sea_level).numerical_value_ ==
|
|
||||||
std::uint8_t(0) - std::uint8_t(1));
|
std::uint8_t(0) - std::uint8_t(1));
|
||||||
static_assert(((mean_sea_level + std::uint8_t(0) * m) - (mean_sea_level + std::uint8_t(1) * m)).numerical_value_ ==
|
static_assert(((mean_sea_level + std::uint8_t(0) * m) - (mean_sea_level + std::uint8_t(1) * m)).numerical_value_ ==
|
||||||
std::uint8_t(0) - std::uint8_t(1));
|
std::uint8_t(0) - std::uint8_t(1));
|
||||||
@@ -1027,32 +1010,32 @@ static_assert(is_of_type<(mean_sea_level + 1 * km) - (mean_sea_level + 1. * m),
|
|||||||
static_assert(is_of_type<(mean_sea_level + 1. * km) - (mean_sea_level + 1. * m), quantity<si::metre, double>>);
|
static_assert(is_of_type<(mean_sea_level + 1. * km) - (mean_sea_level + 1. * m), quantity<si::metre, double>>);
|
||||||
|
|
||||||
|
|
||||||
static_assert(((mean_sea_level + 1 * m) + 1 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 2);
|
static_assert(((mean_sea_level + 1 * m) + 1 * m).quantity_from_origin_.numerical_value_ == 2);
|
||||||
static_assert((1 * m + (mean_sea_level + 1 * m)).quantity_ref_from(mean_sea_level).numerical_value_ == 2);
|
static_assert((1 * m + (mean_sea_level + 1 * m)).quantity_from_origin_.numerical_value_ == 2);
|
||||||
static_assert(((mean_sea_level + 1 * m) + 1 * km).quantity_ref_from(mean_sea_level).numerical_value_ == 1001);
|
static_assert(((mean_sea_level + 1 * m) + 1 * km).quantity_from_origin_.numerical_value_ == 1001);
|
||||||
static_assert((1 * m + (mean_sea_level + 1 * km)).quantity_ref_from(mean_sea_level).numerical_value_ == 1001);
|
static_assert((1 * m + (mean_sea_level + 1 * km)).quantity_from_origin_.numerical_value_ == 1001);
|
||||||
static_assert(((mean_sea_level + 1 * km) + 1 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 1001);
|
static_assert(((mean_sea_level + 1 * km) + 1 * m).quantity_from_origin_.numerical_value_ == 1001);
|
||||||
static_assert((1 * km + (mean_sea_level + 1 * m)).quantity_ref_from(mean_sea_level).numerical_value_ == 1001);
|
static_assert((1 * km + (mean_sea_level + 1 * m)).quantity_from_origin_.numerical_value_ == 1001);
|
||||||
static_assert(((mean_sea_level + 2 * m) - 1 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 1);
|
static_assert(((mean_sea_level + 2 * m) - 1 * m).quantity_from_origin_.numerical_value_ == 1);
|
||||||
static_assert(((mean_sea_level + 1 * km) - 1 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 999);
|
static_assert(((mean_sea_level + 1 * km) - 1 * m).quantity_from_origin_.numerical_value_ == 999);
|
||||||
|
|
||||||
static_assert(((mean_sea_level + 1.5 * m) + 1 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 2.5);
|
static_assert(((mean_sea_level + 1.5 * m) + 1 * m).quantity_from_origin_.numerical_value_ == 2.5);
|
||||||
static_assert((1.5 * m + (mean_sea_level + 1 * m)).quantity_ref_from(mean_sea_level).numerical_value_ == 2.5);
|
static_assert((1.5 * m + (mean_sea_level + 1 * m)).quantity_from_origin_.numerical_value_ == 2.5);
|
||||||
static_assert(((mean_sea_level + 1.5 * m) + 1 * km).quantity_ref_from(mean_sea_level).numerical_value_ == 1001.5);
|
static_assert(((mean_sea_level + 1.5 * m) + 1 * km).quantity_from_origin_.numerical_value_ == 1001.5);
|
||||||
static_assert((1.5 * m + (mean_sea_level + 1 * km)).quantity_ref_from(mean_sea_level).numerical_value_ == 1001.5);
|
static_assert((1.5 * m + (mean_sea_level + 1 * km)).quantity_from_origin_.numerical_value_ == 1001.5);
|
||||||
static_assert(((mean_sea_level + 1.5 * km) + 1 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 1501);
|
static_assert(((mean_sea_level + 1.5 * km) + 1 * m).quantity_from_origin_.numerical_value_ == 1501);
|
||||||
static_assert((1.5 * km + (mean_sea_level + 1 * m)).quantity_ref_from(mean_sea_level).numerical_value_ == 1501);
|
static_assert((1.5 * km + (mean_sea_level + 1 * m)).quantity_from_origin_.numerical_value_ == 1501);
|
||||||
static_assert(((mean_sea_level + 2.5 * m) - 1 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 1.5);
|
static_assert(((mean_sea_level + 2.5 * m) - 1 * m).quantity_from_origin_.numerical_value_ == 1.5);
|
||||||
static_assert(((mean_sea_level + 1.5 * km) - 1 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 1499);
|
static_assert(((mean_sea_level + 1.5 * km) - 1 * m).quantity_from_origin_.numerical_value_ == 1499);
|
||||||
|
|
||||||
static_assert(((mean_sea_level + 1 * m) + 1.5 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 2.5);
|
static_assert(((mean_sea_level + 1 * m) + 1.5 * m).quantity_from_origin_.numerical_value_ == 2.5);
|
||||||
static_assert((1 * m + (mean_sea_level + 1.5 * m)).quantity_ref_from(mean_sea_level).numerical_value_ == 2.5);
|
static_assert((1 * m + (mean_sea_level + 1.5 * m)).quantity_from_origin_.numerical_value_ == 2.5);
|
||||||
static_assert(((mean_sea_level + 1 * m) + 1.5 * km).quantity_ref_from(mean_sea_level).numerical_value_ == 1501);
|
static_assert(((mean_sea_level + 1 * m) + 1.5 * km).quantity_from_origin_.numerical_value_ == 1501);
|
||||||
static_assert((1 * m + (mean_sea_level + 1.5 * km)).quantity_ref_from(mean_sea_level).numerical_value_ == 1501);
|
static_assert((1 * m + (mean_sea_level + 1.5 * km)).quantity_from_origin_.numerical_value_ == 1501);
|
||||||
static_assert(((mean_sea_level + 1 * km) + 1.5 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 1001.5);
|
static_assert(((mean_sea_level + 1 * km) + 1.5 * m).quantity_from_origin_.numerical_value_ == 1001.5);
|
||||||
static_assert((1 * km + (mean_sea_level + 1.5 * m)).quantity_ref_from(mean_sea_level).numerical_value_ == 1001.5);
|
static_assert((1 * km + (mean_sea_level + 1.5 * m)).quantity_from_origin_.numerical_value_ == 1001.5);
|
||||||
static_assert(((mean_sea_level + 2 * m) - 1.5 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 0.5);
|
static_assert(((mean_sea_level + 2 * m) - 1.5 * m).quantity_from_origin_.numerical_value_ == 0.5);
|
||||||
static_assert(((mean_sea_level + 1 * km) - 1.5 * m).quantity_ref_from(mean_sea_level).numerical_value_ == 998.5);
|
static_assert(((mean_sea_level + 1 * km) - 1.5 * m).quantity_from_origin_.numerical_value_ == 998.5);
|
||||||
|
|
||||||
static_assert(((mean_sea_level + 2 * m) - (mean_sea_level + 1 * m)).numerical_value_ == 1);
|
static_assert(((mean_sea_level + 2 * m) - (mean_sea_level + 1 * m)).numerical_value_ == 1);
|
||||||
static_assert(((mean_sea_level + 1 * km) - (mean_sea_level + 1 * m)).numerical_value_ == 999);
|
static_assert(((mean_sea_level + 1 * km) - (mean_sea_level + 1 * m)).numerical_value_ == 999);
|
||||||
@@ -1072,15 +1055,15 @@ static_assert((ground_level + 42 * m) - (other_ground_level + 42 * m) == -81 * m
|
|||||||
static_assert((other_ground_level + 42 * m) - (tower_peak + 42 * m) == 39 * m);
|
static_assert((other_ground_level + 42 * m) - (tower_peak + 42 * m) == 39 * m);
|
||||||
static_assert((tower_peak + 42 * m) - (other_ground_level + 42 * m) == -39 * m);
|
static_assert((tower_peak + 42 * m) - (other_ground_level + 42 * m) == -39 * m);
|
||||||
|
|
||||||
static_assert((mean_sea_level + 42 * m).quantity_ref_from(mean_sea_level) == 42 * m);
|
static_assert((mean_sea_level + 42 * m).quantity_from_origin_ == 42 * m);
|
||||||
static_assert((42 * m + mean_sea_level).quantity_ref_from(mean_sea_level) == 42 * m);
|
static_assert((42 * m + mean_sea_level).quantity_from_origin_ == 42 * m);
|
||||||
static_assert((mean_sea_level - 42 * m).quantity_ref_from(mean_sea_level) == -42 * m);
|
static_assert((mean_sea_level - 42 * m).quantity_from_origin_ == -42 * m);
|
||||||
static_assert((ground_level + 42 * m).quantity_ref_from(ground_level) == 42 * m);
|
static_assert((ground_level + 42 * m).quantity_from_origin_ == 42 * m);
|
||||||
static_assert((42 * m + ground_level).quantity_ref_from(ground_level) == 42 * m);
|
static_assert((42 * m + ground_level).quantity_from_origin_ == 42 * m);
|
||||||
static_assert((ground_level - 42 * m).quantity_ref_from(ground_level) == -42 * m);
|
static_assert((ground_level - 42 * m).quantity_from_origin_ == -42 * m);
|
||||||
static_assert((tower_peak + 42 * m).quantity_ref_from(tower_peak) == 42 * m);
|
static_assert((tower_peak + 42 * m).quantity_from_origin_ == 42 * m);
|
||||||
static_assert((42 * m + tower_peak).quantity_ref_from(tower_peak) == 42 * m);
|
static_assert((42 * m + tower_peak).quantity_from_origin_ == 42 * m);
|
||||||
static_assert((tower_peak - 42 * m).quantity_ref_from(tower_peak) == -42 * m);
|
static_assert((tower_peak - 42 * m).quantity_from_origin_ == -42 * m);
|
||||||
|
|
||||||
static_assert((mean_sea_level + 42 * m) - ground_level == 0 * m);
|
static_assert((mean_sea_level + 42 * m) - ground_level == 0 * m);
|
||||||
static_assert((ground_level + 42 * m) - mean_sea_level == 84 * m);
|
static_assert((ground_level + 42 * m) - mean_sea_level == 84 * m);
|
||||||
@@ -1131,17 +1114,17 @@ inline constexpr struct zero_m_per_s : absolute_point_origin<kind_of<isq::speed>
|
|||||||
|
|
||||||
// commutativity and associativity
|
// commutativity and associativity
|
||||||
static_assert(((zero_m_per_s + 10 * isq::height[m] / (2 * isq::time[s])) + 5 * isq::speed[m / s])
|
static_assert(((zero_m_per_s + 10 * isq::height[m] / (2 * isq::time[s])) + 5 * isq::speed[m / s])
|
||||||
.quantity_ref_from(zero_m_per_s) == 10 * isq::speed[m / s]);
|
.quantity_from_origin_ == 10 * isq::speed[m / s]);
|
||||||
static_assert((10 * isq::height[m] / (2 * isq::time[s]) + (zero_m_per_s + 5 * isq::speed[m / s]))
|
static_assert((10 * isq::height[m] / (2 * isq::time[s]) + (zero_m_per_s + 5 * isq::speed[m / s]))
|
||||||
.quantity_ref_from(zero_m_per_s) == 10 * isq::speed[m / s]);
|
.quantity_from_origin_ == 10 * isq::speed[m / s]);
|
||||||
static_assert(((zero_m_per_s + 5 * isq::speed[m / s]) + 10 * isq::height[m] / (2 * isq::time[s]))
|
static_assert(((zero_m_per_s + 5 * isq::speed[m / s]) + 10 * isq::height[m] / (2 * isq::time[s]))
|
||||||
.quantity_ref_from(zero_m_per_s) == 10 * isq::speed[m / s]);
|
.quantity_from_origin_ == 10 * isq::speed[m / s]);
|
||||||
static_assert((5 * isq::speed[m / s] + (zero_m_per_s + 10 * isq::height[m] / (2 * isq::time[s])))
|
static_assert((5 * isq::speed[m / s] + (zero_m_per_s + 10 * isq::height[m] / (2 * isq::time[s])))
|
||||||
.quantity_ref_from(zero_m_per_s) == 10 * isq::speed[m / s]);
|
.quantity_from_origin_ == 10 * isq::speed[m / s]);
|
||||||
static_assert(((zero_m_per_s + 10 * isq::height[m] / (2 * isq::time[s])) - 5 * isq::speed[m / s])
|
static_assert(((zero_m_per_s + 10 * isq::height[m] / (2 * isq::time[s])) - 5 * isq::speed[m / s])
|
||||||
.quantity_ref_from(zero_m_per_s) == 0 * isq::speed[m / s]);
|
.quantity_from_origin_ == 0 * isq::speed[m / s]);
|
||||||
static_assert(((zero_m_per_s + 5 * isq::speed[m / s]) - 10 * isq::height[m] / (2 * isq::time[s]))
|
static_assert(((zero_m_per_s + 5 * isq::speed[m / s]) - 10 * isq::height[m] / (2 * isq::time[s]))
|
||||||
.quantity_ref_from(zero_m_per_s) == 0 * isq::speed[m / s]);
|
.quantity_from_origin_ == 0 * isq::speed[m / s]);
|
||||||
static_assert((zero_m_per_s + 10 * isq::height[m] / (2 * isq::time[s])) - (zero_m_per_s + 5 * isq::speed[m / s]) ==
|
static_assert((zero_m_per_s + 10 * isq::height[m] / (2 * isq::time[s])) - (zero_m_per_s + 5 * isq::speed[m / s]) ==
|
||||||
0 * isq::speed[m / s]);
|
0 * isq::speed[m / s]);
|
||||||
static_assert((zero_m_per_s + 5 * isq::speed[m / s]) - (zero_m_per_s + 10 * isq::height[m] / (2 * isq::time[s])) ==
|
static_assert((zero_m_per_s + 5 * isq::speed[m / s]) - (zero_m_per_s + 10 * isq::height[m] / (2 * isq::time[s])) ==
|
||||||
@@ -1173,17 +1156,17 @@ static_assert(
|
|||||||
inline constexpr struct zero_Hz : absolute_point_origin<kind_of<isq::frequency>> {
|
inline constexpr struct zero_Hz : absolute_point_origin<kind_of<isq::frequency>> {
|
||||||
} zero_Hz;
|
} zero_Hz;
|
||||||
|
|
||||||
static_assert(((zero_Hz + 10 / (2 * isq::period_duration[s])) + 5 * isq::frequency[Hz]).quantity_ref_from(zero_Hz) ==
|
static_assert(((zero_Hz + 10 / (2 * isq::period_duration[s])) + 5 * isq::frequency[Hz]).quantity_from_origin_ ==
|
||||||
10 * isq::frequency[Hz]);
|
10 * isq::frequency[Hz]);
|
||||||
static_assert((10 / (2 * isq::period_duration[s]) + (zero_Hz + 5 * isq::frequency[Hz])).quantity_ref_from(zero_Hz) ==
|
static_assert((10 / (2 * isq::period_duration[s]) + (zero_Hz + 5 * isq::frequency[Hz])).quantity_from_origin_ ==
|
||||||
10 * isq::frequency[Hz]);
|
10 * isq::frequency[Hz]);
|
||||||
static_assert(((zero_Hz + 5 * isq::frequency[Hz]) + 10 / (2 * isq::period_duration[s])).quantity_ref_from(zero_Hz) ==
|
static_assert(((zero_Hz + 5 * isq::frequency[Hz]) + 10 / (2 * isq::period_duration[s])).quantity_from_origin_ ==
|
||||||
10 * isq::frequency[Hz]);
|
10 * isq::frequency[Hz]);
|
||||||
static_assert((5 * isq::frequency[Hz] + (zero_Hz + 10 / (2 * isq::period_duration[s]))).quantity_ref_from(zero_Hz) ==
|
static_assert((5 * isq::frequency[Hz] + (zero_Hz + 10 / (2 * isq::period_duration[s]))).quantity_from_origin_ ==
|
||||||
10 * isq::frequency[Hz]);
|
10 * isq::frequency[Hz]);
|
||||||
static_assert(((zero_Hz + 10 / (2 * isq::period_duration[s])) - 5 * isq::frequency[Hz]).quantity_ref_from(zero_Hz) ==
|
static_assert(((zero_Hz + 10 / (2 * isq::period_duration[s])) - 5 * isq::frequency[Hz]).quantity_from_origin_ ==
|
||||||
0 * isq::frequency[Hz]);
|
0 * isq::frequency[Hz]);
|
||||||
static_assert(((zero_Hz + 5 * isq::frequency[Hz]) - 10 / (2 * isq::period_duration[s])).quantity_ref_from(zero_Hz) ==
|
static_assert(((zero_Hz + 5 * isq::frequency[Hz]) - 10 / (2 * isq::period_duration[s])).quantity_from_origin_ ==
|
||||||
0 * isq::frequency[Hz]);
|
0 * isq::frequency[Hz]);
|
||||||
static_assert((zero_Hz + 10 / (2 * isq::period_duration[s])) - (zero_Hz + 5 * isq::frequency[Hz]) ==
|
static_assert((zero_Hz + 10 / (2 * isq::period_duration[s])) - (zero_Hz + 5 * isq::frequency[Hz]) ==
|
||||||
0 * isq::frequency[Hz]);
|
0 * isq::frequency[Hz]);
|
||||||
|
Reference in New Issue
Block a user