mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 20:34:26 +02:00
refactor: convertible()
renamed to interconvertible()
This commit is contained in:
@@ -212,7 +212,7 @@ struct derived_dimension_impl : detail::expr_fractions<derived_dimension<>, Ds..
|
|||||||
template<DerivedDimensionSpec... Ds>
|
template<DerivedDimensionSpec... Ds>
|
||||||
struct derived_dimension : detail::derived_dimension_impl<Ds...> {
|
struct derived_dimension : detail::derived_dimension_impl<Ds...> {
|
||||||
template<typename Self, Unit U>
|
template<typename Self, Unit U>
|
||||||
requires valid_unit_for_dimension<U, Self> || (sizeof...(Ds) == 0 && convertible(U{}, one))
|
requires valid_unit_for_dimension<U, Self> || (sizeof...(Ds) == 0 && interconvertible(U{}, one))
|
||||||
[[nodiscard]] constexpr auto operator[](this const Self, U)
|
[[nodiscard]] constexpr auto operator[](this const Self, U)
|
||||||
{
|
{
|
||||||
return reference<Self{}, U{}>{};
|
return reference<Self{}, U{}>{};
|
||||||
@@ -227,7 +227,7 @@ struct derived_dimension;
|
|||||||
template<DerivedDimensionSpec... Ds>
|
template<DerivedDimensionSpec... Ds>
|
||||||
struct derived_dimension<Ds...> : detail::derived_dimension_impl<Ds...> {
|
struct derived_dimension<Ds...> : detail::derived_dimension_impl<Ds...> {
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
requires valid_unit_for_dimension<U, derived_dimension> || (sizeof...(Ds) == 0 && convertible(U{}, one))
|
requires valid_unit_for_dimension<U, derived_dimension> || (sizeof...(Ds) == 0 && interconvertible(U{}, one))
|
||||||
[[nodiscard]] constexpr auto operator[](U) const
|
[[nodiscard]] constexpr auto operator[](U) const
|
||||||
{
|
{
|
||||||
return reference<derived_dimension{}, U{}>{};
|
return reference<derived_dimension{}, U{}>{};
|
||||||
@@ -238,7 +238,7 @@ template<typename Self, DerivedDimension D>
|
|||||||
struct derived_dimension<Self, D> : D {
|
struct derived_dimension<Self, D> : D {
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
requires valid_unit_for_dimension<U, Self> ||
|
requires valid_unit_for_dimension<U, Self> ||
|
||||||
(convertible(derived_dimension{}, derived_dimension<>{}) && convertible(U{}, one))
|
(interconvertible(derived_dimension{}, derived_dimension<>{}) && interconvertible(U{}, one))
|
||||||
[[nodiscard]] constexpr auto operator[](U) const
|
[[nodiscard]] constexpr auto operator[](U) const
|
||||||
{
|
{
|
||||||
return reference<Self{}, U{}>{};
|
return reference<Self{}, U{}>{};
|
||||||
@@ -325,7 +325,7 @@ template<Dimension Lhs, Dimension Rhs>
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<Dimension D1, Dimension D2>
|
template<Dimension D1, Dimension D2>
|
||||||
[[nodiscard]] consteval bool convertible(D1, D2)
|
[[nodiscard]] consteval bool interconvertible(D1, D2)
|
||||||
{
|
{
|
||||||
return std::derived_from<D1, D2> || std::derived_from<D2, D1>;
|
return std::derived_from<D1, D2> || std::derived_from<D2, D1>;
|
||||||
}
|
}
|
||||||
@@ -383,7 +383,7 @@ concept associated_unit = Unit<U> && requires(U u) { get_dimension_for_impl(get_
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<Unit auto U, Dimension auto Dim>
|
template<Unit auto U, Dimension auto Dim>
|
||||||
requires requires { detail::get_dimension_for(U); } && (convertible(Dim, detail::get_dimension_for(U)))
|
requires requires { detail::get_dimension_for(U); } && (interconvertible(Dim, detail::get_dimension_for(U)))
|
||||||
inline constexpr bool is_valid_unit_for_dimension<U, Dim> = true;
|
inline constexpr bool is_valid_unit_for_dimension<U, Dim> = true;
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
@@ -402,7 +402,7 @@ namespace std {
|
|||||||
* the two provided.
|
* the two provided.
|
||||||
*/
|
*/
|
||||||
template<units::Dimension D1, units::Dimension D2>
|
template<units::Dimension D1, units::Dimension D2>
|
||||||
requires(units::convertible(D1{}, D2{}))
|
requires(units::interconvertible(D1{}, D2{}))
|
||||||
struct common_type<D1, D2> {
|
struct common_type<D1, D2> {
|
||||||
using type = ::units::conditional<std::derived_from<std::remove_const_t<D1>, std::remove_const_t<D2>>,
|
using type = ::units::conditional<std::derived_from<std::remove_const_t<D1>, std::remove_const_t<D2>>,
|
||||||
std::remove_const_t<D1>, std::remove_const_t<D2>>;
|
std::remove_const_t<D1>, std::remove_const_t<D2>>;
|
||||||
|
@@ -70,7 +70,7 @@ concept harmonic_ = // exposition only
|
|||||||
template<typename QFrom, typename QTo>
|
template<typename QFrom, typename QTo>
|
||||||
concept quantity_convertible_to_ = // exposition only
|
concept quantity_convertible_to_ = // exposition only
|
||||||
Quantity<QFrom> && Quantity<QTo> &&
|
Quantity<QFrom> && Quantity<QTo> &&
|
||||||
convertible(QFrom::reference, QTo::reference) && scalable_with_<typename QFrom::rep, typename QTo::rep> &&
|
interconvertible(QFrom::reference, QTo::reference) && scalable_with_<typename QFrom::rep, typename QTo::rep> &&
|
||||||
(floating_point_<QTo> || (!floating_point_<QFrom> && harmonic_<QFrom, QTo>));
|
(floating_point_<QTo> || (!floating_point_<QFrom> && harmonic_<QFrom, QTo>));
|
||||||
|
|
||||||
template<typename Func, typename T, typename U>
|
template<typename Func, typename T, typename U>
|
||||||
@@ -470,7 +470,7 @@ explicit quantity(Q) -> quantity<reference<quantity_like_traits<Q>::dimension, q
|
|||||||
|
|
||||||
// non-member binary operators
|
// non-member binary operators
|
||||||
template<Quantity Q1, Quantity Q2>
|
template<Quantity Q1, Quantity Q2>
|
||||||
requires(convertible(Q1::reference, Q2::reference)) &&
|
requires(interconvertible(Q1::reference, Q2::reference)) &&
|
||||||
quantity_value_for_<std::plus<>, typename Q1::rep, typename Q2::rep>
|
quantity_value_for_<std::plus<>, typename Q1::rep, typename Q2::rep>
|
||||||
[[nodiscard]] constexpr Quantity auto operator+(const Q1& lhs, const Q2& rhs)
|
[[nodiscard]] constexpr Quantity auto operator+(const Q1& lhs, const Q2& rhs)
|
||||||
{
|
{
|
||||||
@@ -480,7 +480,7 @@ template<Quantity Q1, Quantity Q2>
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<Quantity Q1, Quantity Q2>
|
template<Quantity Q1, Quantity Q2>
|
||||||
requires(convertible(Q1::reference, Q2::reference)) &&
|
requires(interconvertible(Q1::reference, Q2::reference)) &&
|
||||||
quantity_value_for_<std::minus<>, typename Q1::rep, typename Q2::rep>
|
quantity_value_for_<std::minus<>, typename Q1::rep, typename Q2::rep>
|
||||||
[[nodiscard]] constexpr Quantity auto operator-(const Q1& lhs, const Q2& rhs)
|
[[nodiscard]] constexpr Quantity auto operator-(const Q1& lhs, const Q2& rhs)
|
||||||
{
|
{
|
||||||
@@ -506,7 +506,7 @@ template<Quantity Q1, Quantity Q2>
|
|||||||
|
|
||||||
template<Quantity Q1, Quantity Q2>
|
template<Quantity Q1, Quantity Q2>
|
||||||
requires(!floating_point_<typename Q1::rep>) && (!floating_point_<typename Q2::rep>) &&
|
requires(!floating_point_<typename Q1::rep>) && (!floating_point_<typename Q2::rep>) &&
|
||||||
(convertible(Q1::reference, Q2::reference) || quantity_of<Q2, dimension_one>) &&
|
(interconvertible(Q1::reference, Q2::reference) || quantity_of<Q2, dimension_one>) &&
|
||||||
quantity_value_for_<std::modulus<>, typename Q1::rep, typename Q2::rep>
|
quantity_value_for_<std::modulus<>, typename Q1::rep, typename Q2::rep>
|
||||||
[[nodiscard]] constexpr Quantity auto operator%(const Q1& lhs, const Q2& rhs)
|
[[nodiscard]] constexpr Quantity auto operator%(const Q1& lhs, const Q2& rhs)
|
||||||
{
|
{
|
||||||
@@ -517,7 +517,7 @@ template<Quantity Q1, Quantity Q2>
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<Quantity Q1, Quantity Q2>
|
template<Quantity Q1, Quantity Q2>
|
||||||
requires(convertible(Q1::reference, Q2::reference)) &&
|
requires(interconvertible(Q1::reference, Q2::reference)) &&
|
||||||
std::three_way_comparable_with<typename Q1::rep, typename Q2::rep>
|
std::three_way_comparable_with<typename Q1::rep, typename Q2::rep>
|
||||||
[[nodiscard]] constexpr auto operator<=>(const Q1& lhs, const Q2& rhs)
|
[[nodiscard]] constexpr auto operator<=>(const Q1& lhs, const Q2& rhs)
|
||||||
{
|
{
|
||||||
@@ -526,7 +526,7 @@ template<Quantity Q1, Quantity Q2>
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<Quantity Q1, Quantity Q2>
|
template<Quantity Q1, Quantity Q2>
|
||||||
requires(convertible(Q1::reference, Q2::reference)) &&
|
requires(interconvertible(Q1::reference, Q2::reference)) &&
|
||||||
std::equality_comparable_with<typename Q1::rep, typename Q2::rep>
|
std::equality_comparable_with<typename Q1::rep, typename Q2::rep>
|
||||||
[[nodiscard]] constexpr bool operator==(const Q1& lhs, const Q2& rhs)
|
[[nodiscard]] constexpr bool operator==(const Q1& lhs, const Q2& rhs)
|
||||||
{
|
{
|
||||||
|
@@ -85,7 +85,7 @@ struct cast_traits<From, To> {
|
|||||||
* @tparam To a target quantity type to cast to
|
* @tparam To a target quantity type to cast to
|
||||||
*/
|
*/
|
||||||
template<Quantity To, auto R, scalable_with_<typename To::rep> Rep>
|
template<Quantity To, auto R, scalable_with_<typename To::rep> Rep>
|
||||||
requires(convertible(To::reference, R))
|
requires(interconvertible(To::reference, R))
|
||||||
[[nodiscard]] constexpr auto quantity_cast(const quantity<R, Rep>& q)
|
[[nodiscard]] constexpr auto quantity_cast(const quantity<R, Rep>& q)
|
||||||
{
|
{
|
||||||
if constexpr (R.unit == To::unit) {
|
if constexpr (R.unit == To::unit) {
|
||||||
@@ -122,7 +122,7 @@ template<Quantity To, auto R, scalable_with_<typename To::rep> Rep>
|
|||||||
* @tparam ToU a unit type to use for a target quantity
|
* @tparam ToU a unit type to use for a target quantity
|
||||||
*/
|
*/
|
||||||
template<Reference auto ToR, auto R, typename Rep>
|
template<Reference auto ToR, auto R, typename Rep>
|
||||||
requires(convertible(ToR, R))
|
requires(interconvertible(ToR, R))
|
||||||
[[nodiscard]] constexpr auto quantity_cast(const quantity<R, Rep>& q)
|
[[nodiscard]] constexpr auto quantity_cast(const quantity<R, Rep>& q)
|
||||||
{
|
{
|
||||||
return quantity_cast<quantity<ToR, Rep>>(q);
|
return quantity_cast<quantity<ToR, Rep>>(q);
|
||||||
@@ -142,7 +142,7 @@ template<Reference auto ToR, auto R, typename Rep>
|
|||||||
* @tparam ToD a dimension type to use for a target quantity
|
* @tparam ToD a dimension type to use for a target quantity
|
||||||
*/
|
*/
|
||||||
template<Dimension auto ToD, auto R, typename Rep>
|
template<Dimension auto ToD, auto R, typename Rep>
|
||||||
requires(convertible(ToD, R.dimension))
|
requires(interconvertible(ToD, R.dimension))
|
||||||
[[nodiscard]] constexpr auto quantity_cast(const quantity<R, Rep>& q)
|
[[nodiscard]] constexpr auto quantity_cast(const quantity<R, Rep>& q)
|
||||||
{
|
{
|
||||||
constexpr reference<ToD, quantity<R, Rep>::unit> r;
|
constexpr reference<ToD, quantity<R, Rep>::unit> r;
|
||||||
@@ -162,7 +162,7 @@ template<Dimension auto ToD, auto R, typename Rep>
|
|||||||
* @tparam ToU a unit type to use for a target quantity
|
* @tparam ToU a unit type to use for a target quantity
|
||||||
*/
|
*/
|
||||||
template<Unit auto ToU, auto R, typename Rep>
|
template<Unit auto ToU, auto R, typename Rep>
|
||||||
requires(convertible(ToU, R.unit))
|
requires(interconvertible(ToU, R.unit))
|
||||||
[[nodiscard]] constexpr auto quantity_cast(const quantity<R, Rep>& q)
|
[[nodiscard]] constexpr auto quantity_cast(const quantity<R, Rep>& q)
|
||||||
{
|
{
|
||||||
constexpr reference<quantity<R, Rep>::dimension, ToU> r;
|
constexpr reference<quantity<R, Rep>::dimension, ToU> r;
|
||||||
|
@@ -102,9 +102,9 @@ template<Representation Rep, Reference R>
|
|||||||
void /*Use `q * (1 * r)` rather than `q * r`.*/ operator*(Quantity auto, Reference auto) = delete;
|
void /*Use `q * (1 * r)` rather than `q * r`.*/ operator*(Quantity auto, Reference auto) = delete;
|
||||||
|
|
||||||
template<Reference R1, Reference R2>
|
template<Reference R1, Reference R2>
|
||||||
[[nodiscard]] consteval bool convertible(R1, R2)
|
[[nodiscard]] consteval bool interconvertible(R1, R2)
|
||||||
{
|
{
|
||||||
return convertible(R1::dimension, R2::dimension) && convertible(R1::unit, R2::unit);
|
return interconvertible(R1::dimension, R2::dimension) && interconvertible(R1::unit, R2::unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ struct system_reference {
|
|||||||
static constexpr auto coherent_unit = CoU;
|
static constexpr auto coherent_unit = CoU;
|
||||||
|
|
||||||
template<Unit U>
|
template<Unit U>
|
||||||
requires(convertible(coherent_unit, U{}))
|
requires(interconvertible(coherent_unit, U{}))
|
||||||
[[nodiscard]] constexpr reference<dimension, U{}> operator[](U) const
|
[[nodiscard]] constexpr reference<dimension, U{}> operator[](U) const
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
|
@@ -531,7 +531,7 @@ template<Unit Lhs, Unit Rhs>
|
|||||||
|
|
||||||
// Convertible
|
// Convertible
|
||||||
template<Unit Lhs, Unit Rhs>
|
template<Unit Lhs, Unit Rhs>
|
||||||
[[nodiscard]] consteval bool convertible(Lhs lhs, Rhs rhs)
|
[[nodiscard]] consteval bool interconvertible(Lhs lhs, Rhs rhs)
|
||||||
{
|
{
|
||||||
auto canonical_lhs = detail::get_canonical_unit(lhs);
|
auto canonical_lhs = detail::get_canonical_unit(lhs);
|
||||||
auto canonical_rhs = detail::get_canonical_unit(rhs);
|
auto canonical_rhs = detail::get_canonical_unit(rhs);
|
||||||
@@ -827,7 +827,7 @@ template<typename U1, typename U2>
|
|||||||
namespace std {
|
namespace std {
|
||||||
|
|
||||||
template<units::Unit U1, units::Unit U2>
|
template<units::Unit U1, units::Unit U2>
|
||||||
requires(units::convertible(U1{}, U2{}))
|
requires(units::interconvertible(U1{}, U2{}))
|
||||||
struct common_type<U1, U2> {
|
struct common_type<U1, U2> {
|
||||||
using type = std::remove_const_t<decltype(::units::detail::common_type_impl(U1{}, U2{}))>;
|
using type = std::remove_const_t<decltype(::units::detail::common_type_impl(U1{}, U2{}))>;
|
||||||
};
|
};
|
||||||
|
@@ -171,14 +171,14 @@ static_assert(speed == speed);
|
|||||||
static_assert(length / length == dimension_one);
|
static_assert(length / length == dimension_one);
|
||||||
|
|
||||||
static_assert(1 / time != frequency);
|
static_assert(1 / time != frequency);
|
||||||
static_assert(convertible(1 / time, frequency));
|
static_assert(interconvertible(1 / time, frequency));
|
||||||
static_assert(1 / frequency == time);
|
static_assert(1 / frequency == time);
|
||||||
static_assert(frequency * time == dimension_one);
|
static_assert(frequency * time == dimension_one);
|
||||||
static_assert(std::is_same_v<std::common_type_t<decltype(1 / time), decltype(frequency)>, frequency_>);
|
static_assert(std::is_same_v<std::common_type_t<decltype(1 / time), decltype(frequency)>, frequency_>);
|
||||||
static_assert(std::is_same_v<std::common_type_t<decltype(frequency), decltype(1 / time)>, frequency_>);
|
static_assert(std::is_same_v<std::common_type_t<decltype(frequency), decltype(1 / time)>, frequency_>);
|
||||||
|
|
||||||
static_assert(length * length != area);
|
static_assert(length * length != area);
|
||||||
static_assert(convertible(length * length, area));
|
static_assert(interconvertible(length * length, area));
|
||||||
static_assert(length * length != volume);
|
static_assert(length * length != volume);
|
||||||
static_assert(area / length == length);
|
static_assert(area / length == length);
|
||||||
static_assert(std::is_same_v<std::common_type_t<decltype(length * length), decltype(area)>, area_>);
|
static_assert(std::is_same_v<std::common_type_t<decltype(length * length), decltype(area)>, area_>);
|
||||||
@@ -212,7 +212,7 @@ static_assert(acceleration / speed != frequency);
|
|||||||
|
|
||||||
// comparison of convertible named dimensions
|
// comparison of convertible named dimensions
|
||||||
static_assert(velocity != speed);
|
static_assert(velocity != speed);
|
||||||
static_assert(convertible(speed, velocity));
|
static_assert(interconvertible(speed, velocity));
|
||||||
static_assert(std::is_same_v<std::common_type_t<decltype(velocity), decltype(speed)>, velocity_>);
|
static_assert(std::is_same_v<std::common_type_t<decltype(velocity), decltype(speed)>, velocity_>);
|
||||||
static_assert(std::is_same_v<std::common_type_t<decltype(speed), decltype(velocity)>, velocity_>);
|
static_assert(std::is_same_v<std::common_type_t<decltype(speed), decltype(velocity)>, velocity_>);
|
||||||
|
|
||||||
@@ -220,16 +220,16 @@ static_assert(std::is_same_v<std::common_type_t<decltype(speed), decltype(veloci
|
|||||||
static_assert(is_of_type<mass * acceleration, derived_dimension<length_, mass_, per<units::power<time_, 2>>>>);
|
static_assert(is_of_type<mass * acceleration, derived_dimension<length_, mass_, per<units::power<time_, 2>>>>);
|
||||||
static_assert(is_of_type<acceleration * mass, derived_dimension<length_, mass_, per<units::power<time_, 2>>>>);
|
static_assert(is_of_type<acceleration * mass, derived_dimension<length_, mass_, per<units::power<time_, 2>>>>);
|
||||||
static_assert(mass * acceleration == acceleration * mass);
|
static_assert(mass * acceleration == acceleration * mass);
|
||||||
static_assert(convertible(mass * acceleration, acceleration* mass));
|
static_assert(interconvertible(mass * acceleration, acceleration* mass));
|
||||||
|
|
||||||
// comparisons of equivalent but not convertible dimensions
|
// comparisons of equivalent but not convertible dimensions
|
||||||
static_assert(energy != torque);
|
static_assert(energy != torque);
|
||||||
static_assert(!convertible(energy, torque));
|
static_assert(!interconvertible(energy, torque));
|
||||||
|
|
||||||
static_assert(force * length != energy);
|
static_assert(force * length != energy);
|
||||||
static_assert(force * length != torque);
|
static_assert(force * length != torque);
|
||||||
static_assert(convertible(force * length, energy));
|
static_assert(interconvertible(force * length, energy));
|
||||||
static_assert(convertible(force * length, torque));
|
static_assert(interconvertible(force * length, torque));
|
||||||
template<auto T1, auto T2>
|
template<auto T1, auto T2>
|
||||||
concept no_common_type = requires {
|
concept no_common_type = requires {
|
||||||
requires !requires { typename std::common_type_t<decltype(T1), decltype(T2)>; };
|
requires !requires { typename std::common_type_t<decltype(T1), decltype(T2)>; };
|
||||||
@@ -238,28 +238,28 @@ concept no_common_type = requires {
|
|||||||
static_assert(no_common_type<energy, torque>);
|
static_assert(no_common_type<energy, torque>);
|
||||||
|
|
||||||
static_assert(frequency != action);
|
static_assert(frequency != action);
|
||||||
static_assert(!convertible(frequency, action));
|
static_assert(!interconvertible(frequency, action));
|
||||||
static_assert(no_common_type<frequency, action>);
|
static_assert(no_common_type<frequency, action>);
|
||||||
|
|
||||||
// dimension_one
|
// dimension_one
|
||||||
static_assert(convertible(power / power, efficiency));
|
static_assert(interconvertible(power / power, efficiency));
|
||||||
static_assert(power / power != efficiency);
|
static_assert(power / power != efficiency);
|
||||||
static_assert(dimension_one != efficiency);
|
static_assert(dimension_one != efficiency);
|
||||||
|
|
||||||
static_assert(!convertible(efficiency, strain));
|
static_assert(!interconvertible(efficiency, strain));
|
||||||
static_assert(efficiency != strain);
|
static_assert(efficiency != strain);
|
||||||
|
|
||||||
static_assert(stress / stress != strain);
|
static_assert(stress / stress != strain);
|
||||||
static_assert(stress / stress != efficiency);
|
static_assert(stress / stress != efficiency);
|
||||||
static_assert(convertible(stress / stress, strain));
|
static_assert(interconvertible(stress / stress, strain));
|
||||||
static_assert(convertible(stress / stress, efficiency));
|
static_assert(interconvertible(stress / stress, efficiency));
|
||||||
|
|
||||||
// comparison of not equivalent dimensions
|
// comparison of not equivalent dimensions
|
||||||
static_assert(length != time);
|
static_assert(length != time);
|
||||||
static_assert(!convertible(length, time));
|
static_assert(!interconvertible(length, time));
|
||||||
|
|
||||||
static_assert(acceleration != speed);
|
static_assert(acceleration != speed);
|
||||||
static_assert(!convertible(acceleration, speed));
|
static_assert(!interconvertible(acceleration, speed));
|
||||||
|
|
||||||
// power
|
// power
|
||||||
static_assert(is_of_type<pow<2>(length), derived_dimension<units::power<length_, 2>>>);
|
static_assert(is_of_type<pow<2>(length), derived_dimension<units::power<length_, 2>>>);
|
||||||
|
@@ -118,15 +118,15 @@ static_assert(!NamedUnit<kilometre_>);
|
|||||||
static_assert(is_of_type<metre, metre_>);
|
static_assert(is_of_type<metre, metre_>);
|
||||||
static_assert(is_of_type<get_canonical_unit(metre).reference_unit, metre_>);
|
static_assert(is_of_type<get_canonical_unit(metre).reference_unit, metre_>);
|
||||||
static_assert(get_canonical_unit(metre).mag == mag<1>);
|
static_assert(get_canonical_unit(metre).mag == mag<1>);
|
||||||
static_assert(convertible(metre, metre));
|
static_assert(interconvertible(metre, metre));
|
||||||
static_assert(!convertible(metre, second));
|
static_assert(!interconvertible(metre, second));
|
||||||
static_assert(metre == metre);
|
static_assert(metre == metre);
|
||||||
static_assert(metre != second);
|
static_assert(metre != second);
|
||||||
|
|
||||||
static_assert(is_of_type<degree_Celsius, degree_Celsius_>);
|
static_assert(is_of_type<degree_Celsius, degree_Celsius_>);
|
||||||
static_assert(is_of_type<get_canonical_unit(degree_Celsius).reference_unit, kelvin_>);
|
static_assert(is_of_type<get_canonical_unit(degree_Celsius).reference_unit, kelvin_>);
|
||||||
static_assert(get_canonical_unit(degree_Celsius).mag == mag<1>);
|
static_assert(get_canonical_unit(degree_Celsius).mag == mag<1>);
|
||||||
static_assert(convertible(degree_Celsius, kelvin));
|
static_assert(interconvertible(degree_Celsius, kelvin));
|
||||||
static_assert(degree_Celsius == kelvin);
|
static_assert(degree_Celsius == kelvin);
|
||||||
|
|
||||||
static_assert(is_of_type<radian, radian_>);
|
static_assert(is_of_type<radian, radian_>);
|
||||||
@@ -136,28 +136,28 @@ static_assert(get_canonical_unit(radian).mag == mag<1>);
|
|||||||
static_assert(is_of_type<degree, degree_>);
|
static_assert(is_of_type<degree, degree_>);
|
||||||
static_assert(is_of_type<get_canonical_unit(degree).reference_unit, one_>);
|
static_assert(is_of_type<get_canonical_unit(degree).reference_unit, one_>);
|
||||||
static_assert(get_canonical_unit(degree).mag == mag_pi / mag<180>);
|
static_assert(get_canonical_unit(degree).mag == mag_pi / mag<180>);
|
||||||
static_assert(convertible(radian, degree));
|
static_assert(interconvertible(radian, degree));
|
||||||
static_assert(radian != degree);
|
static_assert(radian != degree);
|
||||||
|
|
||||||
static_assert(is_of_type<steradian, steradian_>);
|
static_assert(is_of_type<steradian, steradian_>);
|
||||||
static_assert(is_of_type<get_canonical_unit(steradian).reference_unit, one_>);
|
static_assert(is_of_type<get_canonical_unit(steradian).reference_unit, one_>);
|
||||||
static_assert(get_canonical_unit(steradian).mag == mag<1>);
|
static_assert(get_canonical_unit(steradian).mag == mag<1>);
|
||||||
static_assert(convertible(radian, steradian)); // !!!
|
static_assert(interconvertible(radian, steradian)); // !!!
|
||||||
static_assert(radian == steradian); // !!!
|
static_assert(radian == steradian); // !!!
|
||||||
|
|
||||||
static_assert(is_of_type<minute, minute_>);
|
static_assert(is_of_type<minute, minute_>);
|
||||||
static_assert(is_of_type<get_canonical_unit(minute).reference_unit, second_>);
|
static_assert(is_of_type<get_canonical_unit(minute).reference_unit, second_>);
|
||||||
static_assert(get_canonical_unit(minute).mag == mag<60>);
|
static_assert(get_canonical_unit(minute).mag == mag<60>);
|
||||||
static_assert(convertible(minute, second));
|
static_assert(interconvertible(minute, second));
|
||||||
static_assert(minute != second);
|
static_assert(minute != second);
|
||||||
|
|
||||||
static_assert(is_of_type<hour, hour_>);
|
static_assert(is_of_type<hour, hour_>);
|
||||||
static_assert(is_of_type<get_canonical_unit(hour).reference_unit, second_>);
|
static_assert(is_of_type<get_canonical_unit(hour).reference_unit, second_>);
|
||||||
static_assert(get_canonical_unit(hour).mag == mag<3600>);
|
static_assert(get_canonical_unit(hour).mag == mag<3600>);
|
||||||
static_assert(convertible(hour, second));
|
static_assert(interconvertible(hour, second));
|
||||||
|
|
||||||
static_assert(convertible(hour, minute));
|
static_assert(interconvertible(hour, minute));
|
||||||
static_assert(convertible(hour, hour));
|
static_assert(interconvertible(hour, hour));
|
||||||
static_assert(hour != second);
|
static_assert(hour != second);
|
||||||
static_assert(hour != minute);
|
static_assert(hour != minute);
|
||||||
static_assert(hour == hour);
|
static_assert(hour == hour);
|
||||||
@@ -166,14 +166,14 @@ static_assert(is_of_type<newton, newton_>);
|
|||||||
static_assert(
|
static_assert(
|
||||||
is_of_type<get_canonical_unit(newton).reference_unit, derived_unit<gram_, metre_, per<power<second_, 2>>>>);
|
is_of_type<get_canonical_unit(newton).reference_unit, derived_unit<gram_, metre_, per<power<second_, 2>>>>);
|
||||||
static_assert(get_canonical_unit(newton).mag == mag<1000>); // !!! (because of kilogram)
|
static_assert(get_canonical_unit(newton).mag == mag<1000>); // !!! (because of kilogram)
|
||||||
static_assert(convertible(newton, newton));
|
static_assert(interconvertible(newton, newton));
|
||||||
static_assert(newton == newton);
|
static_assert(newton == newton);
|
||||||
|
|
||||||
static_assert(is_of_type<joule, joule_>);
|
static_assert(is_of_type<joule, joule_>);
|
||||||
static_assert(
|
static_assert(
|
||||||
is_of_type<get_canonical_unit(joule).reference_unit, derived_unit<gram_, power<metre_, 2>, per<power<second_, 2>>>>);
|
is_of_type<get_canonical_unit(joule).reference_unit, derived_unit<gram_, power<metre_, 2>, per<power<second_, 2>>>>);
|
||||||
static_assert(get_canonical_unit(joule).mag == mag<1000>); // !!! (because of kilogram)
|
static_assert(get_canonical_unit(joule).mag == mag<1000>); // !!! (because of kilogram)
|
||||||
static_assert(convertible(joule, joule));
|
static_assert(interconvertible(joule, joule));
|
||||||
static_assert(joule == joule);
|
static_assert(joule == joule);
|
||||||
static_assert(joule != newton);
|
static_assert(joule != newton);
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ static_assert(is_of_type<nu_second / nu_second, one_>);
|
|||||||
static_assert(is_of_type<kilometre, kilometre_>);
|
static_assert(is_of_type<kilometre, kilometre_>);
|
||||||
static_assert(is_of_type<get_canonical_unit(kilometre).reference_unit, metre_>);
|
static_assert(is_of_type<get_canonical_unit(kilometre).reference_unit, metre_>);
|
||||||
static_assert(get_canonical_unit(kilometre).mag == mag<1000>);
|
static_assert(get_canonical_unit(kilometre).mag == mag<1000>);
|
||||||
static_assert(convertible(kilometre, metre));
|
static_assert(interconvertible(kilometre, metre));
|
||||||
static_assert(kilometre != metre);
|
static_assert(kilometre != metre);
|
||||||
static_assert(kilometre.symbol == "km");
|
static_assert(kilometre.symbol == "km");
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ static_assert(is_of_type<kilojoule, kilojoule_>);
|
|||||||
static_assert(is_of_type<get_canonical_unit(kilojoule).reference_unit,
|
static_assert(is_of_type<get_canonical_unit(kilojoule).reference_unit,
|
||||||
derived_unit<gram_, power<metre_, 2>, per<power<second_, 2>>>>);
|
derived_unit<gram_, power<metre_, 2>, per<power<second_, 2>>>>);
|
||||||
static_assert(get_canonical_unit(kilojoule).mag == mag<1'000'000>);
|
static_assert(get_canonical_unit(kilojoule).mag == mag<1'000'000>);
|
||||||
static_assert(convertible(kilojoule, joule));
|
static_assert(interconvertible(kilojoule, joule));
|
||||||
static_assert(kilojoule != joule);
|
static_assert(kilojoule != joule);
|
||||||
static_assert(kilojoule.symbol == "kJ");
|
static_assert(kilojoule.symbol == "kJ");
|
||||||
|
|
||||||
@@ -407,30 +407,30 @@ static_assert(si::kilo<metre> * si::milli<metre> == si::deca<metre> * si::deci<m
|
|||||||
|
|
||||||
// comparisons of equivalent units (named vs unnamed/derived)
|
// comparisons of equivalent units (named vs unnamed/derived)
|
||||||
static_assert(1 / second == hertz);
|
static_assert(1 / second == hertz);
|
||||||
static_assert(convertible(1 / second, hertz));
|
static_assert(interconvertible(1 / second, hertz));
|
||||||
|
|
||||||
// comparisons of equivalent units of different quantities
|
// comparisons of equivalent units of different quantities
|
||||||
static_assert(hertz == becquerel);
|
static_assert(hertz == becquerel);
|
||||||
static_assert(convertible(hertz, becquerel));
|
static_assert(interconvertible(hertz, becquerel));
|
||||||
|
|
||||||
// comparisons of scaled units
|
// comparisons of scaled units
|
||||||
static_assert(si::kilo<metre> == kilometre);
|
static_assert(si::kilo<metre> == kilometre);
|
||||||
static_assert(mag<1000> * metre == si::kilo<metre>);
|
static_assert(mag<1000> * metre == si::kilo<metre>);
|
||||||
static_assert(mag<1000> * metre == kilometre);
|
static_assert(mag<1000> * metre == kilometre);
|
||||||
static_assert(convertible(si::kilo<metre>, kilometre));
|
static_assert(interconvertible(si::kilo<metre>, kilometre));
|
||||||
static_assert(convertible(mag<1000> * metre, si::kilo<metre>));
|
static_assert(interconvertible(mag<1000> * metre, si::kilo<metre>));
|
||||||
static_assert(convertible(mag<1000> * metre, kilometre));
|
static_assert(interconvertible(mag<1000> * metre, kilometre));
|
||||||
|
|
||||||
static_assert(metre != kilometre);
|
static_assert(metre != kilometre);
|
||||||
static_assert(convertible(metre, kilometre));
|
static_assert(interconvertible(metre, kilometre));
|
||||||
static_assert(mag<100> * metre != kilometre);
|
static_assert(mag<100> * metre != kilometre);
|
||||||
static_assert(convertible(mag<100> * metre, kilometre));
|
static_assert(interconvertible(mag<100> * metre, kilometre));
|
||||||
static_assert(si::milli<metre> != kilometre);
|
static_assert(si::milli<metre> != kilometre);
|
||||||
static_assert(convertible(si::milli<metre>, kilometre));
|
static_assert(interconvertible(si::milli<metre>, kilometre));
|
||||||
|
|
||||||
// comparisons of non-convertible units
|
// comparisons of non-convertible units
|
||||||
static_assert(metre != metre * metre);
|
static_assert(metre != metre * metre);
|
||||||
static_assert(!convertible(metre, metre* metre));
|
static_assert(!interconvertible(metre, metre* metre));
|
||||||
|
|
||||||
// one
|
// one
|
||||||
static_assert(is_of_type<metre / metre, one_>);
|
static_assert(is_of_type<metre / metre, one_>);
|
||||||
|
Reference in New Issue
Block a user