mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 12:54:25 +02:00
fix: parameter constness in constraints
This commit is contained in:
committed by
Mateusz Pusz
parent
6d7cda949e
commit
5c6cd1b26b
@@ -204,14 +204,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
constexpr quantity& operator*=(const rep& rhs)
|
constexpr quantity& operator*=(const rep& rhs)
|
||||||
requires requires(rep a, rep b) { { a *= b } -> std::same_as<rep&>; }
|
requires requires(rep a, const rep b) { { a *= b } -> std::same_as<rep&>; }
|
||||||
{
|
{
|
||||||
value_ *= rhs;
|
value_ *= rhs;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr quantity& operator/=(const rep& rhs)
|
constexpr quantity& operator/=(const rep& rhs)
|
||||||
requires requires(rep a, rep b) { { a /= b } -> std::same_as<rep&>; }
|
requires requires(rep a, const rep b) { { a /= b } -> std::same_as<rep&>; }
|
||||||
{
|
{
|
||||||
value_ /= rhs;
|
value_ /= rhs;
|
||||||
return *this;
|
return *this;
|
||||||
@@ -219,7 +219,7 @@ public:
|
|||||||
|
|
||||||
constexpr quantity& operator%=(const rep& rhs)
|
constexpr quantity& operator%=(const rep& rhs)
|
||||||
requires (!floating_point_<rep>) &&
|
requires (!floating_point_<rep>) &&
|
||||||
requires(rep a, rep b) { { a %= b } -> std::same_as<rep&>; }
|
requires(rep a, const rep b) { { a %= b } -> std::same_as<rep&>; }
|
||||||
{
|
{
|
||||||
value_ %= rhs;
|
value_ %= rhs;
|
||||||
return *this;
|
return *this;
|
||||||
@@ -249,7 +249,7 @@ public:
|
|||||||
|
|
||||||
template<typename Value>
|
template<typename Value>
|
||||||
requires (!Quantity<Value>) &&
|
requires (!Quantity<Value>) &&
|
||||||
invoke_result_convertible_to_<rep, std::multiplies<>, rep, Value>
|
invoke_result_convertible_to_<rep, std::multiplies<>, rep, const Value&>
|
||||||
[[nodiscard]] friend constexpr Quantity auto operator*(const quantity& q, const Value& v)
|
[[nodiscard]] friend constexpr Quantity auto operator*(const quantity& q, const Value& v)
|
||||||
{
|
{
|
||||||
using ret = quantity<D, U, std::invoke_result_t<std::multiplies<>, rep, Value>>;
|
using ret = quantity<D, U, std::invoke_result_t<std::multiplies<>, rep, Value>>;
|
||||||
@@ -258,7 +258,7 @@ public:
|
|||||||
|
|
||||||
template<typename Value>
|
template<typename Value>
|
||||||
requires (!Quantity<Value>) &&
|
requires (!Quantity<Value>) &&
|
||||||
invoke_result_convertible_to_<rep, std::multiplies<>, Value, rep>
|
invoke_result_convertible_to_<rep, std::multiplies<>, const Value&, rep>
|
||||||
[[nodiscard]] friend constexpr Quantity auto operator*(const Value& v, const quantity& q)
|
[[nodiscard]] friend constexpr Quantity auto operator*(const Value& v, const quantity& q)
|
||||||
{
|
{
|
||||||
using ret = quantity<D, U, std::invoke_result_t<std::multiplies<>, Value, rep>>;
|
using ret = quantity<D, U, std::invoke_result_t<std::multiplies<>, Value, rep>>;
|
||||||
@@ -267,7 +267,7 @@ public:
|
|||||||
|
|
||||||
template<typename Value>
|
template<typename Value>
|
||||||
requires (!Quantity<Value>) &&
|
requires (!Quantity<Value>) &&
|
||||||
invoke_result_convertible_to_<rep, std::divides<>, rep, Value>
|
invoke_result_convertible_to_<rep, std::divides<>, rep, const Value&>
|
||||||
[[nodiscard]] friend constexpr Quantity auto operator/(const quantity& q, const Value& v)
|
[[nodiscard]] friend constexpr Quantity auto operator/(const quantity& q, const Value& v)
|
||||||
{
|
{
|
||||||
// Expects(v != zero().count());
|
// Expects(v != zero().count());
|
||||||
@@ -277,7 +277,7 @@ public:
|
|||||||
|
|
||||||
template<typename Value>
|
template<typename Value>
|
||||||
requires (!Quantity<Value>) &&
|
requires (!Quantity<Value>) &&
|
||||||
invoke_result_convertible_to_<rep, std::divides<>, Value, rep>
|
invoke_result_convertible_to_<rep, std::divides<>, const Value&, rep>
|
||||||
[[nodiscard]] friend constexpr Quantity auto operator/(const Value& v, const quantity& q)
|
[[nodiscard]] friend constexpr Quantity auto operator/(const Value& v, const quantity& q)
|
||||||
{
|
{
|
||||||
// Expects(q.count() != zero().count());
|
// Expects(q.count() != zero().count());
|
||||||
@@ -289,7 +289,7 @@ public:
|
|||||||
|
|
||||||
template<typename Value>
|
template<typename Value>
|
||||||
requires (!Quantity<Value>) && (!floating_point_<rep>) && (!floating_point_<Value>) &&
|
requires (!Quantity<Value>) && (!floating_point_<rep>) && (!floating_point_<Value>) &&
|
||||||
invoke_result_convertible_to_<rep, std::modulus<>, rep, Value>
|
invoke_result_convertible_to_<rep, std::modulus<>, rep, const Value&>
|
||||||
[[nodiscard]] friend constexpr Quantity auto operator%(const quantity& q, const Value& v)
|
[[nodiscard]] friend constexpr Quantity auto operator%(const quantity& q, const Value& v)
|
||||||
{
|
{
|
||||||
using ret = quantity<D, U, std::invoke_result_t<std::modulus<>, rep, Value>>;
|
using ret = quantity<D, U, std::invoke_result_t<std::modulus<>, rep, Value>>;
|
||||||
|
Reference in New Issue
Block a user