Add operator/(wxSize, double)
For some reason, while both operator*(wxSize, double) and wxSize::operator/=(double) existed, this one did not, which was unexpected, so add it too.
This commit is contained in:
@@ -435,6 +435,11 @@ inline wxSize operator*(unsigned long i, const wxSize& s)
|
||||
return wxSize(int(s.x * i), int(s.y * i));
|
||||
}
|
||||
|
||||
inline wxSize operator/(const wxSize& s, double i)
|
||||
{
|
||||
return wxSize(wxRound(s.x / i), wxRound(s.y / i));
|
||||
}
|
||||
|
||||
inline wxSize operator*(const wxSize& s, double i)
|
||||
{
|
||||
return wxSize(wxRound(s.x * i), wxRound(s.y * i));
|
||||
|
||||
@@ -1064,12 +1064,19 @@ public:
|
||||
/**
|
||||
@name Miscellaneous operators
|
||||
|
||||
Sizes can be added to or subtracted from each other or divided or
|
||||
multiplied by a number.
|
||||
|
||||
Note that these operators are documented as class members
|
||||
(to make them easier to find) but, as their prototype shows,
|
||||
they are implemented as global operators; note that this is
|
||||
transparent to the user but it helps to understand why the
|
||||
following functions are documented to take the wxSize they
|
||||
operate on as an explicit argument.
|
||||
|
||||
Also note that using @c double factor may result in rounding errors,
|
||||
as wxSize always stores @c int coordinates and the result is always
|
||||
rounded.
|
||||
*/
|
||||
//@{
|
||||
wxSize& operator=(const wxSize& sz);
|
||||
@@ -1083,10 +1090,15 @@ public:
|
||||
wxSize& operator -=(const wxSize& sz);
|
||||
|
||||
wxSize operator /(const wxSize& sz, int factor);
|
||||
wxSize operator /(const wxSize& sz, double factor);
|
||||
wxSize operator *(const wxSize& sz, int factor);
|
||||
wxSize operator *(const wxSize& sz, double factor);
|
||||
wxSize operator *(int factor, const wxSize& sz);
|
||||
wxSize operator *(double factor, const wxSize& sz);
|
||||
wxSize& operator /=(int factor);
|
||||
wxSize& operator /=(double factor);
|
||||
wxSize& operator *=(int factor);
|
||||
wxSize& operator *=(double factor);
|
||||
//@}
|
||||
};
|
||||
|
||||
|
||||
@@ -48,4 +48,6 @@ TEST_CASE("wxSize::Operators", "[size]")
|
||||
CHECK( s3 == wxSize(2, 4) );
|
||||
s3 /= 2;
|
||||
CHECK( s3 == s1 );
|
||||
|
||||
CHECK( wxSize(6, 9) / 1.5 == wxSize(4, 6) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user