forked from mpusz/mp-units
test: compile quantity_test.cpp with -DUNITS_DOWNCAST_MODE=0
This commit is contained in:
committed by
Mateusz Pusz
parent
b18061ab0e
commit
3002c5673d
@@ -50,7 +50,7 @@ template<typename QFrom, typename QTo>
|
||||
concept harmonic_ = // exposition only
|
||||
Quantity<QFrom> &&
|
||||
Quantity<QTo> &&
|
||||
requires(QFrom from, QTo to) { requires is_integral(detail::quantity_ratio(from) / detail::quantity_ratio(to)); };
|
||||
is_integral(detail::quantity_ratio<QFrom> / detail::quantity_ratio<QTo>);
|
||||
|
||||
template<typename QFrom, typename QTo>
|
||||
concept safe_castable_to_ = // exposition only
|
||||
@@ -136,6 +136,11 @@ public:
|
||||
constexpr explicit(!(is_same_v<dimension, dim_one> && is_same_v<unit, ::units::one>))
|
||||
quantity(const Value& v) : value_(v) {}
|
||||
|
||||
template<safe_convertible_to_<rep> Value>
|
||||
requires is_same_v<dimension, unknown_dimension<>>
|
||||
constexpr explicit(!(is_same_v<dimension, unknown_dimension<>> && unit::ratio == ratio{1, 1, 0}))
|
||||
quantity(const Value& v) : value_(v) {}
|
||||
|
||||
template<safe_castable_to_<quantity> Q>
|
||||
constexpr explicit(false) quantity(const Q& q) : value_(quantity_cast<quantity>(q).count()) {}
|
||||
|
||||
@@ -269,30 +274,30 @@ public:
|
||||
// Below friend functions are to be found via argument-dependent lookup only
|
||||
template<typename Value>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator+(const quantity& lhs, const Value& rhs)
|
||||
requires (!Quantity<Value>) && is_same_v<unit, units::one> &&
|
||||
invoke_result_convertible_to_<rep, std::plus<>, rep, Value>
|
||||
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>;
|
||||
requires invoke_result_convertible_to_<rep, std::plus<>, rep, Value>; }
|
||||
{
|
||||
return units::quantity(lhs.count() + rhs);
|
||||
}
|
||||
template<typename Value>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator+(const Value& lhs, const quantity& rhs)
|
||||
requires (!Quantity<Value>) && is_same_v<unit, units::one> &&
|
||||
invoke_result_convertible_to_<rep, std::plus<>, Value, rep>
|
||||
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>;
|
||||
requires invoke_result_convertible_to_<rep, std::plus<>, Value, rep>; }
|
||||
{
|
||||
return units::quantity(lhs + rhs.count());
|
||||
}
|
||||
|
||||
template<typename Value>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator-(const quantity& lhs, const Value& rhs)
|
||||
requires (!Quantity<Value>) && is_same_v<unit, units::one> &&
|
||||
invoke_result_convertible_to_<rep, std::minus<>, rep, Value>
|
||||
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>;
|
||||
requires invoke_result_convertible_to_<rep, std::minus<>, rep, Value>; }
|
||||
{
|
||||
return units::quantity(lhs.count() - rhs);
|
||||
}
|
||||
template<typename Value>
|
||||
[[nodiscard]] friend constexpr Quantity auto operator-(const Value& lhs, const quantity& rhs)
|
||||
requires (!Quantity<Value>) && is_same_v<unit, units::one> &&
|
||||
invoke_result_convertible_to_<rep, std::minus<>, Value, rep>
|
||||
requires requires { requires !Quantity<Value>; requires is_same_v<unit, units::one>;
|
||||
requires invoke_result_convertible_to_<rep, std::minus<>, Value, rep>; }
|
||||
{
|
||||
return units::quantity(lhs - rhs.count());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user