mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-01 19:34:29 +02:00
refactor: usage of v
for the function argument name changed to prevent shadowing errors
This commit is contained in:
@@ -129,8 +129,8 @@ std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>&
|
|||||||
template<typename T, typename Validator, typename Char>
|
template<typename T, typename Validator, typename Char>
|
||||||
struct MP_UNITS_STD_FMT::formatter<validated_type<T, Validator>, Char> : formatter<T, Char> {
|
struct MP_UNITS_STD_FMT::formatter<validated_type<T, Validator>, Char> : formatter<T, Char> {
|
||||||
template<typename FormatContext>
|
template<typename FormatContext>
|
||||||
auto format(const validated_type<T, Validator>& v, FormatContext& ctx) const -> decltype(ctx.out())
|
auto format(const validated_type<T, Validator>& val, FormatContext& ctx) const -> decltype(ctx.out())
|
||||||
{
|
{
|
||||||
return formatter<T, Char>::format(v.value(), ctx);
|
return formatter<T, Char>::format(val.value(), ctx);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -163,16 +163,16 @@ public:
|
|||||||
lhs._coordinates_[2] == rhs._coordinates_[2];
|
lhs._coordinates_[2] == rhs._coordinates_[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] friend constexpr T norm(const cartesian_vector& v)
|
[[nodiscard]] friend constexpr T norm(const cartesian_vector& vec)
|
||||||
requires treat_as_floating_point<T>
|
requires treat_as_floating_point<T>
|
||||||
{
|
{
|
||||||
return v.magnitude();
|
return vec.magnitude();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] friend constexpr cartesian_vector unit_vector(const cartesian_vector& v)
|
[[nodiscard]] friend constexpr cartesian_vector unit_vector(const cartesian_vector& vec)
|
||||||
requires treat_as_floating_point<T>
|
requires treat_as_floating_point<T>
|
||||||
{
|
{
|
||||||
return v.unit();
|
return vec.unit();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<std::same_as<T> U, typename V>
|
template<std::same_as<T> U, typename V>
|
||||||
@@ -200,9 +200,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if MP_UNITS_HOSTED
|
#if MP_UNITS_HOSTED
|
||||||
friend constexpr std::ostream& operator<<(std::ostream& os, const cartesian_vector& v)
|
friend constexpr std::ostream& operator<<(std::ostream& os, const cartesian_vector& vec)
|
||||||
{
|
{
|
||||||
return os << '[' << v[0] << ", " << v[1] << ", " << v[2] << ']';
|
return os << '[' << vec[0] << ", " << vec[1] << ", " << vec[2] << ']';
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -222,9 +222,9 @@ template<typename T, typename Char>
|
|||||||
struct MP_UNITS_STD_FMT::formatter<mp_units::cartesian_vector<T>, Char> :
|
struct MP_UNITS_STD_FMT::formatter<mp_units::cartesian_vector<T>, Char> :
|
||||||
formatter<std::basic_string_view<Char>, Char> {
|
formatter<std::basic_string_view<Char>, Char> {
|
||||||
template<typename FormatContext>
|
template<typename FormatContext>
|
||||||
auto format(const mp_units::cartesian_vector<T>& v, FormatContext& ctx) const
|
auto format(const mp_units::cartesian_vector<T>& vec, FormatContext& ctx) const
|
||||||
{
|
{
|
||||||
return format_to(ctx.out(), "[{}, {}, {}]", v[0], v[1], v[2]);
|
return format_to(ctx.out(), "[{}, {}, {}]", vec[0], vec[1], vec[2]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@@ -90,16 +90,16 @@ public:
|
|||||||
constexpr T* data() noexcept { return data_; }
|
constexpr T* data() noexcept { return data_; }
|
||||||
constexpr const T* data() const noexcept { return data_; }
|
constexpr const T* data() const noexcept { return data_; }
|
||||||
|
|
||||||
constexpr reference push_back(const T& v)
|
constexpr reference push_back(const T& val)
|
||||||
requires std::constructible_from<T, const T&>
|
requires std::constructible_from<T, const T&>
|
||||||
{
|
{
|
||||||
return emplace_back(v);
|
return emplace_back(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr reference push_back(T&& v)
|
constexpr reference push_back(T&& val)
|
||||||
requires std::constructible_from<T, T&&>
|
requires std::constructible_from<T, T&&>
|
||||||
{
|
{
|
||||||
return emplace_back(std::forward<T&&>(v));
|
return emplace_back(std::forward<T&&>(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
|
@@ -174,21 +174,21 @@ public:
|
|||||||
|
|
||||||
template<typename FwdValue, Reference R2>
|
template<typename FwdValue, Reference R2>
|
||||||
requires detail::SameValueAs<R2{}, R, std::remove_cvref_t<FwdValue>, Rep>
|
requires detail::SameValueAs<R2{}, R, std::remove_cvref_t<FwdValue>, Rep>
|
||||||
constexpr quantity(FwdValue&& v, R2) : numerical_value_is_an_implementation_detail_(std::forward<FwdValue>(v))
|
constexpr quantity(FwdValue&& val, R2) : numerical_value_is_an_implementation_detail_(std::forward<FwdValue>(val))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename FwdValue, Reference R2, typename Value = std::remove_cvref_t<FwdValue>>
|
template<typename FwdValue, Reference R2, typename Value = std::remove_cvref_t<FwdValue>>
|
||||||
requires(!detail::SameValueAs<R2{}, R, Value, Rep>) &&
|
requires(!detail::SameValueAs<R2{}, R, Value, Rep>) &&
|
||||||
detail::QuantityConvertibleTo<quantity<R2{}, Value>, quantity>
|
detail::QuantityConvertibleTo<quantity<R2{}, Value>, quantity>
|
||||||
constexpr quantity(FwdValue&& v, R2) : quantity(quantity<R2{}, Value>{std::forward<FwdValue>(v), R2{}})
|
constexpr quantity(FwdValue&& val, R2) : quantity(quantity<R2{}, Value>{std::forward<FwdValue>(val), R2{}})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<detail::ValuePreservingTo<Rep> FwdValue>
|
template<detail::ValuePreservingTo<Rep> FwdValue>
|
||||||
requires(unit == ::mp_units::one)
|
requires(unit == ::mp_units::one)
|
||||||
constexpr explicit(false) quantity(FwdValue&& v) :
|
constexpr explicit(false) quantity(FwdValue&& val) :
|
||||||
numerical_value_is_an_implementation_detail_(std::forward<FwdValue>(v))
|
numerical_value_is_an_implementation_detail_(std::forward<FwdValue>(val))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,9 +214,9 @@ public:
|
|||||||
|
|
||||||
template<detail::ValuePreservingTo<Rep> FwdValue>
|
template<detail::ValuePreservingTo<Rep> FwdValue>
|
||||||
requires(unit == ::mp_units::one)
|
requires(unit == ::mp_units::one)
|
||||||
constexpr quantity& operator=(FwdValue&& v)
|
constexpr quantity& operator=(FwdValue&& val)
|
||||||
{
|
{
|
||||||
numerical_value_is_an_implementation_detail_ = std::forward<FwdValue>(v);
|
numerical_value_is_an_implementation_detail_ = std::forward<FwdValue>(val);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,11 +422,11 @@ public:
|
|||||||
requires(!Quantity<Value>) && requires(rep a, Value b) {
|
requires(!Quantity<Value>) && requires(rep a, Value b) {
|
||||||
{ a *= b } -> std::same_as<rep&>;
|
{ a *= b } -> std::same_as<rep&>;
|
||||||
}
|
}
|
||||||
friend constexpr decltype(auto) operator*=(Q&& lhs, const Value& v)
|
friend constexpr decltype(auto) operator*=(Q&& lhs, const Value& val)
|
||||||
{
|
{
|
||||||
// TODO use *= when compiler bug is resolved:
|
// TODO use *= when compiler bug is resolved:
|
||||||
// https://developercommunity.visualstudio.com/t/Discrepancy-in-Behavior-of-operator-an/10732445
|
// https://developercommunity.visualstudio.com/t/Discrepancy-in-Behavior-of-operator-an/10732445
|
||||||
lhs.numerical_value_is_an_implementation_detail_ = lhs.numerical_value_is_an_implementation_detail_ * v;
|
lhs.numerical_value_is_an_implementation_detail_ = lhs.numerical_value_is_an_implementation_detail_ * val;
|
||||||
return std::forward<Q>(lhs);
|
return std::forward<Q>(lhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,12 +444,12 @@ public:
|
|||||||
requires(!Quantity<Value>) && requires(rep a, Value b) {
|
requires(!Quantity<Value>) && requires(rep a, Value b) {
|
||||||
{ a /= b } -> std::same_as<rep&>;
|
{ a /= b } -> std::same_as<rep&>;
|
||||||
}
|
}
|
||||||
friend constexpr decltype(auto) operator/=(Q&& lhs, const Value& v)
|
friend constexpr decltype(auto) operator/=(Q&& lhs, const Value& val)
|
||||||
{
|
{
|
||||||
MP_UNITS_EXPECTS_DEBUG(v != quantity_values<Value>::zero());
|
MP_UNITS_EXPECTS_DEBUG(val != quantity_values<Value>::zero());
|
||||||
// TODO use /= when compiler bug is resolved:
|
// TODO use /= when compiler bug is resolved:
|
||||||
// https://developercommunity.visualstudio.com/t/Discrepancy-in-Behavior-of-operator-an/10732445
|
// https://developercommunity.visualstudio.com/t/Discrepancy-in-Behavior-of-operator-an/10732445
|
||||||
lhs.numerical_value_is_an_implementation_detail_ = lhs.numerical_value_is_an_implementation_detail_ / v;
|
lhs.numerical_value_is_an_implementation_detail_ = lhs.numerical_value_is_an_implementation_detail_ / val;
|
||||||
return std::forward<Q>(lhs);
|
return std::forward<Q>(lhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,17 +551,17 @@ public:
|
|||||||
template<std::derived_from<quantity> Q, typename Value>
|
template<std::derived_from<quantity> Q, typename Value>
|
||||||
requires(!Quantity<Value>) &&
|
requires(!Quantity<Value>) &&
|
||||||
(!Reference<Value>) && detail::InvokeResultOf<quantity_spec, std::multiplies<>, Rep, const Value&>
|
(!Reference<Value>) && detail::InvokeResultOf<quantity_spec, std::multiplies<>, Rep, const Value&>
|
||||||
[[nodiscard]] friend constexpr QuantityOf<quantity_spec> auto operator*(const Q& q, const Value& v)
|
[[nodiscard]] friend constexpr QuantityOf<quantity_spec> auto operator*(const Q& q, const Value& val)
|
||||||
{
|
{
|
||||||
return ::mp_units::quantity{q.numerical_value_ref_in(unit) * v, R};
|
return ::mp_units::quantity{q.numerical_value_ref_in(unit) * val, R};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Value, std::derived_from<quantity> Q>
|
template<typename Value, std::derived_from<quantity> Q>
|
||||||
requires(!Quantity<Value>) &&
|
requires(!Quantity<Value>) &&
|
||||||
(!Reference<Value>) && detail::InvokeResultOf<quantity_spec, std::multiplies<>, const Value&, Rep>
|
(!Reference<Value>) && detail::InvokeResultOf<quantity_spec, std::multiplies<>, const Value&, Rep>
|
||||||
[[nodiscard]] friend constexpr QuantityOf<quantity_spec> auto operator*(const Value& v, const Q& q)
|
[[nodiscard]] friend constexpr QuantityOf<quantity_spec> auto operator*(const Value& val, const Q& q)
|
||||||
{
|
{
|
||||||
return ::mp_units::quantity{v * q.numerical_value_ref_in(unit), R};
|
return ::mp_units::quantity{val * q.numerical_value_ref_in(unit), R};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<std::derived_from<quantity> Q, auto R2, typename Rep2>
|
template<std::derived_from<quantity> Q, auto R2, typename Rep2>
|
||||||
@@ -575,18 +575,18 @@ public:
|
|||||||
template<std::derived_from<quantity> Q, typename Value>
|
template<std::derived_from<quantity> Q, typename Value>
|
||||||
requires(!Quantity<Value>) &&
|
requires(!Quantity<Value>) &&
|
||||||
(!Reference<Value>) && detail::InvokeResultOf<quantity_spec, std::divides<>, Rep, const Value&>
|
(!Reference<Value>) && detail::InvokeResultOf<quantity_spec, std::divides<>, Rep, const Value&>
|
||||||
[[nodiscard]] friend constexpr QuantityOf<quantity_spec> auto operator/(const Q& q, const Value& v)
|
[[nodiscard]] friend constexpr QuantityOf<quantity_spec> auto operator/(const Q& q, const Value& val)
|
||||||
{
|
{
|
||||||
MP_UNITS_EXPECTS_DEBUG(v != quantity_values<Value>::zero());
|
MP_UNITS_EXPECTS_DEBUG(val != quantity_values<Value>::zero());
|
||||||
return ::mp_units::quantity{q.numerical_value_ref_in(unit) / v, R};
|
return ::mp_units::quantity{q.numerical_value_ref_in(unit) / val, R};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Value, std::derived_from<quantity> Q>
|
template<typename Value, std::derived_from<quantity> Q>
|
||||||
requires(!Quantity<Value>) &&
|
requires(!Quantity<Value>) &&
|
||||||
(!Reference<Value>) && detail::InvokeResultOf<quantity_spec, std::divides<>, const Value&, Rep>
|
(!Reference<Value>) && detail::InvokeResultOf<quantity_spec, std::divides<>, const Value&, Rep>
|
||||||
[[nodiscard]] friend constexpr QuantityOf<inverse(quantity_spec)> auto operator/(const Value& v, const Q& q)
|
[[nodiscard]] friend constexpr QuantityOf<inverse(quantity_spec)> auto operator/(const Value& val, const Q& q)
|
||||||
{
|
{
|
||||||
return ::mp_units::quantity{v / q.numerical_value_ref_in(unit), ::mp_units::one / R};
|
return ::mp_units::quantity{val / q.numerical_value_ref_in(unit), ::mp_units::one / R};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<std::derived_from<quantity> Q, auto R2, typename Rep2>
|
template<std::derived_from<quantity> Q, auto R2, typename Rep2>
|
||||||
|
@@ -68,8 +68,8 @@ void to_stream_impl(std::basic_ostream<CharT, Traits>& os, const quantity<R, Rep
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename CharT, class Traits, typename T>
|
template<typename CharT, class Traits, typename T>
|
||||||
std::basic_ostream<CharT, Traits>& to_stream(std::basic_ostream<CharT, Traits>& os, const T& v)
|
std::basic_ostream<CharT, Traits>& to_stream(std::basic_ostream<CharT, Traits>& os, const T& val)
|
||||||
requires requires { detail::to_stream_impl(os, v); }
|
requires requires { detail::to_stream_impl(os, val); }
|
||||||
{
|
{
|
||||||
if (os.width()) {
|
if (os.width()) {
|
||||||
// std::setw() applies to the whole output so it has to be first put into std::string
|
// std::setw() applies to the whole output so it has to be first put into std::string
|
||||||
@@ -77,11 +77,11 @@ std::basic_ostream<CharT, Traits>& to_stream(std::basic_ostream<CharT, Traits>&
|
|||||||
oss.flags(os.flags());
|
oss.flags(os.flags());
|
||||||
oss.imbue(os.getloc());
|
oss.imbue(os.getloc());
|
||||||
oss.precision(os.precision());
|
oss.precision(os.precision());
|
||||||
detail::to_stream_impl(oss, v);
|
detail::to_stream_impl(oss, val);
|
||||||
return os << std::move(oss).str();
|
return os << std::move(oss).str();
|
||||||
}
|
}
|
||||||
|
|
||||||
detail::to_stream_impl(os, v);
|
detail::to_stream_impl(os, val);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,10 +93,10 @@ constexpr bool is_mp_units_stream = requires(OStream os, T v) { detail::to_strea
|
|||||||
MP_UNITS_EXPORT_BEGIN
|
MP_UNITS_EXPORT_BEGIN
|
||||||
|
|
||||||
template<typename CharT, typename Traits, typename T>
|
template<typename CharT, typename Traits, typename T>
|
||||||
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const T& v)
|
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, const T& val)
|
||||||
requires detail::is_mp_units_stream<std::basic_ostream<CharT, Traits>, T>
|
requires detail::is_mp_units_stream<std::basic_ostream<CharT, Traits>, T>
|
||||||
{
|
{
|
||||||
return detail::to_stream(os, v);
|
return detail::to_stream(os, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
MP_UNITS_EXPORT_END
|
MP_UNITS_EXPORT_END
|
||||||
|
@@ -83,10 +83,10 @@ struct quantity_like_traits<std::chrono::duration<Rep, Period>> {
|
|||||||
return q.count();
|
return q.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] static constexpr T from_numerical_value(const rep& v) noexcept(
|
[[nodiscard]] static constexpr T from_numerical_value(const rep& val) noexcept(
|
||||||
std::is_nothrow_copy_constructible_v<rep>)
|
std::is_nothrow_copy_constructible_v<rep>)
|
||||||
{
|
{
|
||||||
return T(v);
|
return T(val);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -113,10 +113,10 @@ struct quantity_point_like_traits<std::chrono::time_point<C, std::chrono::durati
|
|||||||
return tp.time_since_epoch().count();
|
return tp.time_since_epoch().count();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] static constexpr T from_numerical_value(const rep& v) noexcept(
|
[[nodiscard]] static constexpr T from_numerical_value(const rep& val) noexcept(
|
||||||
std::is_nothrow_copy_constructible_v<rep>)
|
std::is_nothrow_copy_constructible_v<rep>)
|
||||||
{
|
{
|
||||||
return T(std::chrono::duration<Rep, Period>(v));
|
return T(std::chrono::duration<Rep, Period>(val));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user