mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Point: Fix incorrect type conversions in operator* and operator/
This commit is contained in:
parent
03bdbb5364
commit
754ec66b42
1 changed files with 14 additions and 4 deletions
|
|
@ -120,12 +120,22 @@ public:
|
|||
Point& operator/= (Point<OtherType> other) noexcept { *this = *this / other; return *this; }
|
||||
|
||||
/** Returns a point whose coordinates are multiplied by a given scalar value. */
|
||||
template <typename FloatType>
|
||||
constexpr Point operator* (FloatType multiplier) const noexcept { return Point ((ValueType) ((FloatType) x * multiplier), (ValueType) ((FloatType) y * multiplier)); }
|
||||
template <typename OtherType>
|
||||
constexpr Point operator* (OtherType multiplier) const noexcept
|
||||
{
|
||||
using CommonType = typename std::common_type<ValueType, OtherType>::type;
|
||||
return Point ((ValueType) ((CommonType) x * (CommonType) multiplier),
|
||||
(ValueType) ((CommonType) y * (CommonType) multiplier));
|
||||
}
|
||||
|
||||
/** Returns a point whose coordinates are divided by a given scalar value. */
|
||||
template <typename FloatType>
|
||||
constexpr Point operator/ (FloatType divisor) const noexcept { return Point ((ValueType) ((FloatType) x / divisor), (ValueType) ((FloatType) y / divisor)); }
|
||||
template <typename OtherType>
|
||||
constexpr Point operator/ (OtherType divisor) const noexcept
|
||||
{
|
||||
using CommonType = typename std::common_type<ValueType, OtherType>::type;
|
||||
return Point ((ValueType) ((CommonType) x / (CommonType) divisor),
|
||||
(ValueType) ((CommonType) y / (CommonType) divisor));
|
||||
}
|
||||
|
||||
/** Multiplies the point's coordinates by a scalar value. */
|
||||
template <typename FloatType>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue