Merge branch 'downcasting_2.0'
This commit is contained in:
commit
e367afed71
22 files changed
+300
-145
No files matched your search
@@ -50,6 +50,8 @@ static_assert(centimetre::symbol == "cm");
|
||||
|
||||
// speed
|
||||
|
||||
static_assert((10_q_cm / 5_q_s).count() == 2);
|
||||
static_assert((2_q_cm_per_s).count() == 2);
|
||||
static_assert(10_q_cm / 5_q_s == 2_q_cm_per_s);
|
||||
static_assert(10_q_cm / 2_q_cm_per_s == 5_q_s);
|
||||
static_assert(10_q_cm == 2_q_cm_per_s * 5_q_s);
|
||||
@@ -59,7 +61,11 @@ static_assert(detail::unit_text<dim_speed, centimetre_per_second>() == "cm/s");
|
||||
// area
|
||||
static_assert(centimetre::ratio / dimension_unit<dim_length>::ratio == ratio(1));
|
||||
|
||||
static_assert((1_q_cm * 1_q_cm).count() == 1);
|
||||
static_assert((1_q_cm2).count() == 1);
|
||||
static_assert(1_q_cm * 1_q_cm == 1_q_cm2);
|
||||
static_assert(100_q_cm * 100_q_cm == area<physical::si::square_metre>(1));
|
||||
static_assert(100_q_cm * 100_q_cm == length<physical::si::metre>(1) * length<physical::si::metre>(1));
|
||||
static_assert(100_q_cm2 / 10_q_cm == 10_q_cm);
|
||||
|
||||
static_assert(detail::unit_text<dim_area, square_centimetre>() == basic_symbol_text("cm²", "cm^2"));
|
||||
|
||||
@@ -49,11 +49,14 @@ using amplitude_spectral_density = quantity<dim_amplitude_spectral_density, U, R
|
||||
|
||||
namespace {
|
||||
|
||||
static_assert(is_same_v<dimension_sqrt<dim_power_spectral_density>, dim_amplitude_spectral_density>);
|
||||
static_assert(is_same_v<dimension_pow<dim_amplitude_spectral_density, 2>, dim_power_spectral_density>);
|
||||
template<typename T, typename U>
|
||||
inline constexpr bool compare = DOWNCAST_MODE != 0 ? is_same_v<T, U> : (is_same_v<T, U> || units::equivalent<T, U>);
|
||||
|
||||
static_assert(is_same_v<decltype(pow<2>(amplitude_spectral_density<volt_per_sqrt_hertz>(4))), decltype(power_spectral_density<volt2_per_hertz>(16))>);
|
||||
static_assert(is_same_v<decltype(sqrt(power_spectral_density<volt2_per_hertz>(16))), decltype(amplitude_spectral_density<volt_per_sqrt_hertz>(4))>);
|
||||
static_assert(compare<dimension_sqrt<dim_power_spectral_density>, dim_amplitude_spectral_density>);
|
||||
static_assert(compare<dimension_pow<dim_amplitude_spectral_density, 2>, dim_power_spectral_density>);
|
||||
|
||||
static_assert(compare<decltype(pow<2>(amplitude_spectral_density<volt_per_sqrt_hertz>(4))), decltype(power_spectral_density<volt2_per_hertz>(16))>);
|
||||
static_assert(compare<decltype(sqrt(power_spectral_density<volt2_per_hertz>(16))), decltype(amplitude_spectral_density<volt_per_sqrt_hertz>(4))>);
|
||||
|
||||
}
|
||||
|
||||
@@ -63,6 +66,5 @@ struct kilogram_per_second : unit<kilogram_per_second> {};
|
||||
struct dim_mass_rate : derived_dimension<dim_mass_rate, kilogram_per_second, units::exponent<dim_mass, 1>, units::exponent<dim_time, -1>> {};
|
||||
struct kilogram_per_hour : deduced_unit<kilogram_per_hour, dim_mass_rate, kilogram, hour> {};
|
||||
constexpr auto a = 1_q_kg / 1_q_h;
|
||||
static_assert(is_same_v<decltype(a)::unit, kilogram_per_hour>);
|
||||
|
||||
}
|
||||
@@ -20,6 +20,8 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
#include "units/math.h"
|
||||
#include "units/physical/international/area.h"
|
||||
#include "units/physical/si/area.h"
|
||||
#include "units/physical/si/speed.h"
|
||||
#include "units/physical/international/area.h"
|
||||
@@ -27,18 +29,20 @@
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace units;
|
||||
using namespace units::physical::si::literals;
|
||||
using namespace units::physical::international::literals;
|
||||
using namespace units;
|
||||
using namespace units::physical::si::literals;
|
||||
using namespace units::physical::international::literals;
|
||||
|
||||
static_assert(is_same_v<decltype(pow<0>(2_q_m)), std::int64_t>);
|
||||
static_assert(is_same_v<decltype(pow<1>(2_q_m)), decltype(2_q_m)>);
|
||||
static_assert(is_same_v<decltype(pow<2>(2_q_m)), decltype(4_q_m2)>);
|
||||
static_assert(is_same_v<decltype(pow<2>(2_q_km)), decltype(4_q_km2)>);
|
||||
static_assert(is_same_v<decltype(pow<2>(2_q_ft)), decltype(4_q_ft2)>);
|
||||
static_assert(is_same_v<decltype(sqrt(4_q_m2)), decltype(2_q_m)>);
|
||||
static_assert(is_same_v<decltype(sqrt(4_q_km2)), decltype(2_q_km)>);
|
||||
static_assert(is_same_v<decltype(sqrt(4_q_ft2)), decltype(2_q_ft)>);
|
||||
template<typename T, typename U>
|
||||
inline constexpr bool compare = DOWNCAST_MODE != 0 ? is_same_v<T, U> : (is_same_v<T, U> || units::equivalent<T, U>);
|
||||
|
||||
static_assert(compare<decltype(pow<0>(2_q_m)), std::int64_t>);
|
||||
static_assert(compare<decltype(pow<1>(2_q_m)), decltype(2_q_m)>);
|
||||
static_assert(compare<decltype(pow<2>(2_q_m)), decltype(4_q_m2)>);
|
||||
static_assert(compare<decltype(pow<2>(2_q_km)), decltype(4_q_km2)>);
|
||||
static_assert(compare<decltype(pow<2>(2_q_ft)), decltype(4_q_ft2)>);
|
||||
static_assert(compare<decltype(sqrt(4_q_m2)), decltype(2_q_m)>);
|
||||
static_assert(compare<decltype(sqrt(4_q_km2)), decltype(2_q_km)>);
|
||||
static_assert(compare<decltype(sqrt(4_q_ft2)), decltype(2_q_ft)>);
|
||||
|
||||
} // namespace
|
||||
@@ -35,6 +35,9 @@ namespace {
|
||||
using namespace units;
|
||||
using namespace units::physical::si;
|
||||
|
||||
template<typename T, typename U>
|
||||
inline constexpr bool compare = DOWNCAST_MODE != 0 ? std::is_same_v<T, U> : (std::is_same_v<T, U> || units::equivalent<T, U>);
|
||||
|
||||
// class invariants
|
||||
|
||||
template<typename DimLength>
|
||||
@@ -119,23 +122,23 @@ static_assert((quantity_point(2_q_m) -= 1_q_m).relative().count() == 1);
|
||||
|
||||
// non-member arithmetic operators
|
||||
|
||||
static_assert(is_same_v<decltype(quantity_point<dim_length, metre, int>() + length<metre, double>()),
|
||||
static_assert(compare<decltype(quantity_point<dim_length, metre, int>() + length<metre, double>()),
|
||||
quantity_point<dim_length, metre, double>>);
|
||||
static_assert(is_same_v<decltype(length<metre, int>() + quantity_point<dim_length, metre, double>()),
|
||||
static_assert(compare<decltype(length<metre, int>() + quantity_point<dim_length, metre, double>()),
|
||||
quantity_point<dim_length, metre, double>>);
|
||||
static_assert(is_same_v<decltype(quantity_point<dim_length, kilometre, int>() + length<metre, double>()),
|
||||
static_assert(compare<decltype(quantity_point<dim_length, kilometre, int>() + length<metre, double>()),
|
||||
quantity_point<dim_length, metre, double>>);
|
||||
static_assert(is_same_v<decltype(length<kilometre, int>() + quantity_point<dim_length, metre, double>()),
|
||||
static_assert(compare<decltype(length<kilometre, int>() + quantity_point<dim_length, metre, double>()),
|
||||
quantity_point<dim_length, metre, double>>);
|
||||
static_assert(is_same_v<decltype(quantity_point<dim_length, metre, double>() - length<metre, int>()),
|
||||
static_assert(compare<decltype(quantity_point<dim_length, metre, double>() - length<metre, int>()),
|
||||
quantity_point<dim_length, metre, double>>);
|
||||
static_assert(is_same_v<decltype(quantity_point<dim_length, kilometre, double>() - length<metre, int>()),
|
||||
static_assert(compare<decltype(quantity_point<dim_length, kilometre, double>() - length<metre, int>()),
|
||||
quantity_point<dim_length, metre, double>>);
|
||||
static_assert(
|
||||
is_same_v<decltype(quantity_point<dim_length, metre, double>() - quantity_point<dim_length, metre, int>()),
|
||||
compare<decltype(quantity_point<dim_length, metre, double>() - quantity_point<dim_length, metre, int>()),
|
||||
length<metre, double>>);
|
||||
static_assert(
|
||||
is_same_v<decltype(quantity_point<dim_length, kilometre, double>() - quantity_point<dim_length, metre, int>()),
|
||||
compare<decltype(quantity_point<dim_length, kilometre, double>() - quantity_point<dim_length, metre, int>()),
|
||||
length<metre, double>>);
|
||||
|
||||
static_assert((1_q_m + km).relative().count() == 1001);
|
||||
@@ -187,13 +190,13 @@ static_assert(QuantityPoint<quantity_point<dim_length, millimetre, int>>);
|
||||
|
||||
// common_quantity_point
|
||||
|
||||
static_assert(is_same_v<
|
||||
static_assert(compare<
|
||||
common_quantity_point<quantity_point<dim_length, metre, int>, quantity_point<dim_length, kilometre, int>>,
|
||||
quantity_point<dim_length, metre, int>>);
|
||||
static_assert(is_same_v<common_quantity_point<quantity_point<dim_length, kilometre, long long>,
|
||||
static_assert(compare<common_quantity_point<quantity_point<dim_length, kilometre, long long>,
|
||||
quantity_point<dim_length, metre, int>>,
|
||||
quantity_point<dim_length, metre, long long>>);
|
||||
static_assert(is_same_v<common_quantity_point<quantity_point<dim_length, kilometre, long long>,
|
||||
static_assert(compare<common_quantity_point<quantity_point<dim_length, kilometre, long long>,
|
||||
quantity_point<dim_length, millimetre, double>>,
|
||||
quantity_point<dim_length, millimetre, double>>);
|
||||
|
||||
@@ -208,8 +211,7 @@ static_assert(std::equality_comparable_with<decltype(quantity_point(1_q_m)), dec
|
||||
|
||||
// quantity_cast
|
||||
|
||||
static_assert(
|
||||
is_same_v<decltype(quantity_point_cast<scaled_unit<ratio(1), metre>>(quantity_point(2_q_km)))::unit, metre>);
|
||||
static_assert(compare<decltype(quantity_point_cast<scaled_unit<ratio(1), metre>>(quantity_point(2_q_km)))::unit, metre>);
|
||||
|
||||
static_assert(quantity_point_cast<quantity_point<dim_length, metre, int>>(quantity_point(2_q_km)).relative().count() ==
|
||||
2000);
|
||||
|
||||
@@ -34,6 +34,9 @@ namespace {
|
||||
using namespace units;
|
||||
using namespace units::physical::si;
|
||||
|
||||
template<typename T, typename U>
|
||||
inline constexpr bool compare = DOWNCAST_MODE != 0 ? std::is_same_v<T, U> : (std::is_same_v<T, U> || units::equivalent<T, U>);
|
||||
|
||||
// class invariants
|
||||
|
||||
template<typename DimLength>
|
||||
@@ -147,37 +150,35 @@ static_assert(invalid_compound_assignments<metre>);
|
||||
|
||||
// non-member arithmetic operators
|
||||
|
||||
static_assert(is_same_v<decltype(length<metre, int>() + length<metre, double>()), length<metre, double>>);
|
||||
static_assert(is_same_v<decltype(length<metre, int>() + length<metre, double>()), length<metre, double>>);
|
||||
static_assert(compare<decltype(length<metre, int>() + length<metre, double>()), length<metre, double>>);
|
||||
static_assert(compare<decltype(length<metre, int>() + length<metre, double>()), length<metre, double>>);
|
||||
static_assert(compare<decltype(length<kilometre, int>() + length<metre, double>()), length<metre, double>>);
|
||||
static_assert(compare<decltype(length<metre, double>() - length<metre, int>()), length<metre, double>>);
|
||||
static_assert(compare<decltype(length<kilometre, double>() - length<metre, int>()), length<metre, double>>);
|
||||
static_assert(compare<decltype(length<metre, int>() * 1.0), length<metre, double>>);
|
||||
static_assert(compare<decltype(1.0 * length<metre, int>()), length<metre, double>>);
|
||||
static_assert(
|
||||
is_same_v<decltype(length<kilometre, int>() + length<metre, double>()), length<metre, double>>);
|
||||
static_assert(is_same_v<decltype(length<metre, double>() - length<metre, int>()), length<metre, double>>);
|
||||
compare<decltype(speed<metre_per_second, int>() * physical::si::time<second, int>()), length<metre, int>>);
|
||||
static_assert(
|
||||
is_same_v<decltype(length<kilometre, double>() - length<metre, int>()), length<metre, double>>);
|
||||
static_assert(is_same_v<decltype(length<metre, int>() * 1.0), length<metre, double>>);
|
||||
static_assert(is_same_v<decltype(1.0 * length<metre, int>()), length<metre, double>>);
|
||||
static_assert(
|
||||
is_same_v<decltype(speed<metre_per_second, int>() * physical::si::time<second, int>()), length<metre, int>>);
|
||||
static_assert(
|
||||
is_same_v<decltype(speed<metre_per_second, int>() * physical::si::time<hour, int>()), length<scaled_unit<ratio(36, 1, 2), metre>, int>>);
|
||||
static_assert(is_same_v<decltype(length<metre>() * physical::si::time<minute>()),
|
||||
compare<decltype(speed<metre_per_second, int>() * physical::si::time<hour, int>()), length<scaled_unit<ratio(36, 1, 2), metre>, int>>);
|
||||
static_assert(compare<decltype(length<metre>() * physical::si::time<minute>()),
|
||||
quantity<unknown_dimension<units::exponent<dim_length, 1>, units::exponent<dim_time, 1>>, scaled_unit<ratio(6, 1, 1), unknown_coherent_unit>>>);
|
||||
static_assert(is_same_v<decltype(1 / physical::si::time<second, int>()), frequency<hertz, int>>);
|
||||
static_assert(is_same_v<decltype(1 / physical::si::time<minute, int>()), frequency<scaled_unit<ratio(1, 6, -1), hertz>, int>>);
|
||||
static_assert(is_same_v<decltype(1 / frequency<hertz, int>()), physical::si::time<second, int>>);
|
||||
static_assert(is_same_v<decltype(1 / length<kilometre>()),
|
||||
static_assert(compare<decltype(1 / physical::si::time<second, int>()), frequency<hertz, int>>);
|
||||
static_assert(compare<decltype(1 / physical::si::time<minute, int>()), frequency<scaled_unit<ratio(1, 6, -1), hertz>, int>>);
|
||||
static_assert(compare<decltype(1 / frequency<hertz, int>()), physical::si::time<second, int>>);
|
||||
static_assert(compare<decltype(1 / length<kilometre>()),
|
||||
quantity<unknown_dimension<units::exponent<dim_length, -1>>, scaled_unit<ratio(1, 1, -3), unknown_coherent_unit>>>);
|
||||
static_assert(is_same_v<decltype(length<metre, int>() / 1.0), length<metre, double>>);
|
||||
static_assert(is_same_v<decltype(length<metre, int>() / length<metre, double>()), dimensionless<one, double>>);
|
||||
static_assert(is_same_v<decltype(length<kilometre, int>() / length<metre, double>()), dimensionless<scaled_unit<ratio(1, 1, 3), one>, double>>);
|
||||
static_assert(compare<decltype(length<metre, int>() / 1.0), length<metre, double>>);
|
||||
static_assert(compare<decltype(length<metre, int>() / length<metre, double>()), dimensionless<one, double>>);
|
||||
static_assert(compare<decltype(length<kilometre, int>() / length<metre, double>()), dimensionless<scaled_unit<ratio(1, 1, 3), one>, double>>);
|
||||
static_assert(
|
||||
is_same_v<decltype(length<metre, int>() / physical::si::time<second, int>()), speed<metre_per_second, int>>);
|
||||
compare<decltype(length<metre, int>() / physical::si::time<second, int>()), speed<metre_per_second, int>>);
|
||||
static_assert(
|
||||
is_same_v<decltype(length<metre>() / physical::si::time<minute>()), speed<scaled_unit<ratio(1, 6, -1), metre_per_second>>>);
|
||||
static_assert(is_same_v<decltype(physical::si::time<minute>() / length<metre>()),
|
||||
compare<decltype(length<metre>() / physical::si::time<minute>()), speed<scaled_unit<ratio(1, 6, -1), metre_per_second>>>);
|
||||
static_assert(compare<decltype(physical::si::time<minute>() / length<metre>()),
|
||||
quantity<unknown_dimension<units::exponent<dim_length, -1>, units::exponent<dim_time, 1>>, scaled_unit<ratio(6 ,1 , 1), unknown_coherent_unit>>>);
|
||||
static_assert(is_same_v<decltype(length<metre, int>() % short(1)), length<metre, int>>);
|
||||
static_assert(is_same_v<decltype(length<metre, int>() % length<metre, short>(1)), length<metre, int>>);
|
||||
static_assert(compare<decltype(length<metre, int>() % short(1)), length<metre, int>>);
|
||||
static_assert(compare<decltype(length<metre, int>() % length<metre, short>(1)), length<metre, int>>);
|
||||
|
||||
static_assert((1_q_m + km).count() == 1001);
|
||||
static_assert((1_q_m + 1_q_km).count() == 1001);
|
||||
@@ -251,11 +252,10 @@ static_assert(Quantity<length<millimetre, int>>);
|
||||
|
||||
// common_quantity
|
||||
|
||||
static_assert(is_same_v<common_quantity<length<metre, int>, length<kilometre, int>>, length<metre, int>>);
|
||||
static_assert(compare<common_quantity<length<metre, int>, length<kilometre, int>>, length<metre, int>>);
|
||||
static_assert(compare<common_quantity<length<kilometre, long long>, length<metre, int>>, length<metre, long long>>);
|
||||
static_assert(
|
||||
is_same_v<common_quantity<length<kilometre, long long>, length<metre, int>>, length<metre, long long>>);
|
||||
static_assert(is_same_v<common_quantity<length<kilometre, long long>, length<millimetre, double>>,
|
||||
length<millimetre, double>>);
|
||||
compare<common_quantity<length<kilometre, long long>, length<millimetre, double>>, length<millimetre, double>>);
|
||||
|
||||
// common_type
|
||||
|
||||
@@ -272,7 +272,7 @@ static_assert(!std::equality_comparable_with<dimensionless<one, int>, double>);
|
||||
|
||||
// quantity_cast
|
||||
|
||||
static_assert(is_same_v<decltype(quantity_cast<scaled_unit<ratio(1), metre>>(2_q_km))::unit, metre>);
|
||||
static_assert(compare<decltype(quantity_cast<scaled_unit<ratio(1), metre>>(2_q_km))::unit, metre>);
|
||||
|
||||
static_assert(quantity_cast<length<metre, int>>(2_q_km).count() == 2000);
|
||||
static_assert(quantity_cast<length<kilometre, int>>(2000_q_m).count() == 2);
|
||||
@@ -339,6 +339,20 @@ static_assert(1_q_km / 1_q_s == 1000_q_m_per_s);
|
||||
static_assert(2_q_km_per_h * 2_q_h == 4_q_km);
|
||||
static_assert(2_q_km / 2_q_km_per_h == 1_q_h);
|
||||
|
||||
static_assert(is_same_v<decltype(pow<2>(2_q_m)), decltype(4_q_m2)>);
|
||||
static_assert(compare<decltype(pow<2>(2_q_m)), decltype(4_q_m2)>);
|
||||
|
||||
// downcasting
|
||||
|
||||
#if DOWNCAST_MODE == 0
|
||||
|
||||
static_assert(std::is_same_v<decltype(10_q_m / 5_q_s), quantity<unknown_dimension<units::exp<dim_length, 1>, units::exp<dim_time, -1>>, scaled_unit<ratio(1), unknown_coherent_unit>, std::int64_t>>);
|
||||
static_assert(std::is_same_v<decltype(1_q_mm + 1_q_km), length<scaled_unit<ratio(1, 1, -3), metre>, std::int64_t>>);
|
||||
|
||||
#else
|
||||
|
||||
static_assert(std::is_same_v<decltype(10_q_m / 5_q_s), speed<metre_per_second, std::int64_t>>);
|
||||
static_assert(std::is_same_v<decltype(1_q_mm + 1_q_km), length<millimetre, std::int64_t>>);
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
@@ -46,6 +46,13 @@ namespace {
|
||||
|
||||
using namespace units::physical;
|
||||
|
||||
static_assert(units::detail::quantity_ratio(si::length<si::metre>(1)) == units::ratio(1));
|
||||
static_assert(units::detail::quantity_ratio(cgs::length<cgs::centimetre>(1)) == units::ratio(1, 100));
|
||||
static_assert(units::detail::quantity_ratio(si::speed<si::metre_per_second>(1)) == units::ratio(1));
|
||||
static_assert(units::detail::quantity_ratio(cgs::speed<cgs::centimetre_per_second>(1)) == units::ratio(1, 100));
|
||||
static_assert(units::detail::quantity_ratio(si::force<si::newton>(1)) == units::ratio(1000)); // defined in terms of kilogram that are 1000 * gram
|
||||
static_assert(units::detail::quantity_ratio(cgs::force<cgs::dyne>(1)) == units::ratio(1, 100)); // defined in terms of gram so only centimetre ratio counts here
|
||||
|
||||
static_assert(cgs::length<cgs::centimetre>(100) == si::length<si::metre>(1));
|
||||
static_assert(cgs::mass<cgs::gram>(1'000) == si::mass<si::kilogram>(1));
|
||||
static_assert(cgs::time<cgs::second>(1) == si::time<si::second>(1));
|
||||
|
||||
@@ -241,8 +241,6 @@ static_assert(kilogray::symbol == "kGy");
|
||||
|
||||
// speed
|
||||
|
||||
static_assert(is_same_v<decltype(1_q_km / 1_q_s), speed<scaled_unit<ratio(1, 1, 3), metre_per_second>, std::int64_t>>);
|
||||
|
||||
static_assert(10_q_m / 5_q_s == 2_q_m_per_s);
|
||||
static_assert(10 / 5_q_s * 1_q_m == 2_q_m_per_s);
|
||||
static_assert(1_q_km / 1_q_s == 1000_q_m_per_s);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
// SOFTWARE.
|
||||
|
||||
#include "units/unit.h"
|
||||
#include "units/bits/equivalent.h"
|
||||
#include "units/physical/si/prefixes.h"
|
||||
|
||||
namespace {
|
||||
@@ -28,6 +29,9 @@ namespace {
|
||||
using namespace units;
|
||||
using namespace units::physical;
|
||||
|
||||
template<typename T, typename U>
|
||||
inline constexpr bool compare = DOWNCAST_MODE != 0 ? std::is_same_v<T, U> : (std::is_same_v<T, U> || units::equivalent<T, U>);
|
||||
|
||||
struct metre : named_unit<metre, "m", si::prefix> {};
|
||||
struct centimetre : prefixed_unit<centimetre, si::centi, metre> {};
|
||||
struct kilometre : prefixed_unit<kilometre, si::kilo, metre> {};
|
||||
@@ -49,11 +53,11 @@ struct metre_per_second : unit<metre_per_second> {};
|
||||
struct dim_speed : derived_dimension<dim_speed, metre_per_second, units::exponent<dim_length, 1>, units::exponent<dim_time, -1>> {};
|
||||
struct kilometre_per_hour : deduced_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
|
||||
|
||||
static_assert(is_same_v<downcast<scaled_unit<ratio(1), metre>>, metre>);
|
||||
static_assert(is_same_v<downcast<scaled_unit<ratio(1, 1, -2), metre>>, centimetre>);
|
||||
static_assert(is_same_v<downcast<scaled_unit<ratio(yard::ratio.num, yard::ratio.den, yard::ratio.exp), metre>>, yard>);
|
||||
static_assert(is_same_v<downcast<scaled_unit<yard::ratio * ratio(1, 3), metre>>, foot>);
|
||||
static_assert(is_same_v<downcast<scaled_unit<kilometre::ratio / hour::ratio, metre_per_second>>, kilometre_per_hour>);
|
||||
static_assert(compare<downcast<scaled_unit<ratio(1), metre>>, metre>);
|
||||
static_assert(compare<downcast<scaled_unit<ratio(1, 1, -2), metre>>, centimetre>);
|
||||
static_assert(compare<downcast<scaled_unit<ratio(yard::ratio.num, yard::ratio.den, yard::ratio.exp), metre>>, yard>);
|
||||
static_assert(compare<downcast<scaled_unit<yard::ratio * ratio(1, 3), metre>>, foot>);
|
||||
static_assert(compare<downcast<scaled_unit<kilometre::ratio / hour::ratio, metre_per_second>>, kilometre_per_hour>);
|
||||
|
||||
#if COMP_GCC >= 10
|
||||
static_assert([]<ratio R>() { return !requires { typename scaled_unit<R, metre>; }; }.template operator()<ratio(-1, 1)>()); // negative unit ratio
|
||||
|
||||
Reference in new issue
Block a user