fix: operator +-*/ should return const object
This commit is contained in:
parent
ab2757375d
commit
1ed684f3a1
|
|
@ -40,27 +40,27 @@ namespace easy2d
|
|||
height = other.height;
|
||||
}
|
||||
|
||||
Size Size::operator+(const Size & other) const
|
||||
const Size Size::operator+(const Size & other) const
|
||||
{
|
||||
return Size(width + other.width, height + other.height);
|
||||
}
|
||||
|
||||
Size Size::operator-(const Size & other) const
|
||||
const Size Size::operator-(const Size & other) const
|
||||
{
|
||||
return Size(width - other.width, height - other.height);
|
||||
}
|
||||
|
||||
Size Size::operator*(float val) const
|
||||
const Size Size::operator*(float val) const
|
||||
{
|
||||
return Size(width * val, height * val);
|
||||
}
|
||||
|
||||
Size Size::operator/(float val) const
|
||||
const Size Size::operator/(float val) const
|
||||
{
|
||||
return Size(width / val, height / val);
|
||||
}
|
||||
|
||||
Size Size::operator-() const
|
||||
const Size Size::operator-() const
|
||||
{
|
||||
return Size(-width, -height);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ namespace easy2d
|
|||
const Size& other
|
||||
);
|
||||
|
||||
Size operator + (const Size & other) const;
|
||||
Size operator - (const Size & other) const;
|
||||
Size operator * (float val) const;
|
||||
Size operator / (float val) const;
|
||||
Size operator - () const;
|
||||
const Size operator + (const Size & other) const;
|
||||
const Size operator - (const Size & other) const;
|
||||
const Size operator * (float val) const;
|
||||
const Size operator / (float val) const;
|
||||
const Size operator - () const;
|
||||
bool operator== (const Size& other) const;
|
||||
|
||||
inline operator D2D1_SIZE_F () const
|
||||
|
|
|
|||
|
|
@ -66,12 +66,12 @@ namespace easy2d
|
|||
return !!dur_since_epoch_.Milliseconds();
|
||||
}
|
||||
|
||||
TimePoint TimePoint::operator+(const Duration & dur) const
|
||||
const TimePoint TimePoint::operator+(const Duration & dur) const
|
||||
{
|
||||
return TimePoint(dur_since_epoch_ + dur);
|
||||
}
|
||||
|
||||
TimePoint TimePoint::operator-(const Duration & dur) const
|
||||
const TimePoint TimePoint::operator-(const Duration & dur) const
|
||||
{
|
||||
return TimePoint(dur_since_epoch_ - dur);
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ namespace easy2d
|
|||
return (*this);
|
||||
}
|
||||
|
||||
Duration TimePoint::operator-(const TimePoint & other) const
|
||||
const Duration TimePoint::operator-(const TimePoint & other) const
|
||||
{
|
||||
return dur_since_epoch_ - other.dur_since_epoch_;
|
||||
}
|
||||
|
|
@ -246,67 +246,67 @@ namespace easy2d
|
|||
return milliseconds_ <= other.milliseconds_;
|
||||
}
|
||||
|
||||
Duration Duration::operator+(const Duration & other) const
|
||||
const Duration Duration::operator+(const Duration & other) const
|
||||
{
|
||||
return Duration(milliseconds_ + other.milliseconds_);
|
||||
}
|
||||
|
||||
Duration Duration::operator-(const Duration & other) const
|
||||
const Duration Duration::operator-(const Duration & other) const
|
||||
{
|
||||
return Duration(milliseconds_ - other.milliseconds_);
|
||||
}
|
||||
|
||||
Duration Duration::operator-() const
|
||||
const Duration Duration::operator-() const
|
||||
{
|
||||
return Duration(-milliseconds_);
|
||||
}
|
||||
|
||||
Duration Duration::operator*(int val) const
|
||||
const Duration Duration::operator*(int val) const
|
||||
{
|
||||
return Duration(milliseconds_ * val);
|
||||
}
|
||||
|
||||
Duration Duration::operator/(int val) const
|
||||
const Duration Duration::operator/(int val) const
|
||||
{
|
||||
return Duration(milliseconds_ / val);
|
||||
}
|
||||
|
||||
Duration easy2d::time::Duration::operator*(unsigned long long val) const
|
||||
const Duration easy2d::time::Duration::operator*(unsigned long long val) const
|
||||
{
|
||||
return Duration(static_cast<int64_t>(milliseconds_ * val));
|
||||
}
|
||||
|
||||
Duration easy2d::time::Duration::operator/(unsigned long long val) const
|
||||
const Duration easy2d::time::Duration::operator/(unsigned long long val) const
|
||||
{
|
||||
return Duration(static_cast<int64_t>(milliseconds_ / val));
|
||||
}
|
||||
|
||||
Duration Duration::operator*(float val) const
|
||||
const Duration Duration::operator*(float val) const
|
||||
{
|
||||
return Duration(static_cast<int64_t>(milliseconds_ * val));
|
||||
}
|
||||
|
||||
Duration Duration::operator/(float val) const
|
||||
const Duration Duration::operator/(float val) const
|
||||
{
|
||||
return Duration(static_cast<int64_t>(milliseconds_ / val));
|
||||
}
|
||||
|
||||
Duration Duration::operator*(double val) const
|
||||
const Duration Duration::operator*(double val) const
|
||||
{
|
||||
return Duration(static_cast<int64_t>(milliseconds_ * val));
|
||||
}
|
||||
|
||||
Duration Duration::operator*(long double val) const
|
||||
const Duration Duration::operator*(long double val) const
|
||||
{
|
||||
return Duration(static_cast<int64_t>(milliseconds_ * val));
|
||||
}
|
||||
|
||||
Duration Duration::operator/(double val) const
|
||||
const Duration Duration::operator/(double val) const
|
||||
{
|
||||
return Duration(static_cast<int64_t>(milliseconds_ / val));
|
||||
}
|
||||
|
||||
Duration Duration::operator/(long double val) const
|
||||
const Duration Duration::operator/(long double val) const
|
||||
{
|
||||
return Duration(static_cast<int64_t>(milliseconds_ / val));
|
||||
}
|
||||
|
|
@ -383,52 +383,52 @@ namespace easy2d
|
|||
return (*this);
|
||||
}
|
||||
|
||||
Duration easy2d::time::operator*(int val, const Duration & dur)
|
||||
const Duration easy2d::time::operator*(int val, const Duration & dur)
|
||||
{
|
||||
return dur * val;
|
||||
}
|
||||
|
||||
Duration easy2d::time::operator*(unsigned long long val, const Duration & dur)
|
||||
const Duration easy2d::time::operator*(unsigned long long val, const Duration & dur)
|
||||
{
|
||||
return dur / val;
|
||||
}
|
||||
|
||||
Duration easy2d::time::operator/(int val, const Duration & dur)
|
||||
const Duration easy2d::time::operator/(int val, const Duration & dur)
|
||||
{
|
||||
return dur / val;
|
||||
}
|
||||
|
||||
Duration easy2d::time::operator/(unsigned long long val, const Duration & dur)
|
||||
const Duration easy2d::time::operator/(unsigned long long val, const Duration & dur)
|
||||
{
|
||||
return dur * val;
|
||||
}
|
||||
|
||||
Duration easy2d::time::operator*(float val, const Duration & dur)
|
||||
const Duration easy2d::time::operator*(float val, const Duration & dur)
|
||||
{
|
||||
return dur * val;
|
||||
}
|
||||
|
||||
Duration easy2d::time::operator/(float val, const Duration & dur)
|
||||
const Duration easy2d::time::operator/(float val, const Duration & dur)
|
||||
{
|
||||
return dur / val;
|
||||
}
|
||||
|
||||
Duration easy2d::time::operator*(double val, const Duration & dur)
|
||||
const Duration easy2d::time::operator*(double val, const Duration & dur)
|
||||
{
|
||||
return dur * val;
|
||||
}
|
||||
|
||||
Duration easy2d::time::operator/(double val, const Duration & dur)
|
||||
const Duration easy2d::time::operator/(double val, const Duration & dur)
|
||||
{
|
||||
return dur / val;
|
||||
}
|
||||
|
||||
Duration easy2d::time::operator*(long double val, const Duration & dur)
|
||||
const Duration easy2d::time::operator*(long double val, const Duration & dur)
|
||||
{
|
||||
return dur * val;
|
||||
}
|
||||
|
||||
Duration easy2d::time::operator/(long double val, const Duration & dur)
|
||||
const Duration easy2d::time::operator/(long double val, const Duration & dur)
|
||||
{
|
||||
return dur / val;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,19 +70,19 @@ namespace easy2d
|
|||
bool operator< (const Duration &) const;
|
||||
bool operator<= (const Duration &) const;
|
||||
|
||||
Duration operator + (const Duration &) const;
|
||||
Duration operator - (const Duration &) const;
|
||||
Duration operator - () const;
|
||||
Duration operator * (int) const;
|
||||
Duration operator * (unsigned long long) const;
|
||||
Duration operator * (float) const;
|
||||
Duration operator * (double) const;
|
||||
Duration operator * (long double) const;
|
||||
Duration operator / (int) const;
|
||||
Duration operator / (unsigned long long) const;
|
||||
Duration operator / (float) const;
|
||||
Duration operator / (double) const;
|
||||
Duration operator / (long double) const;
|
||||
const Duration operator + (const Duration &) const;
|
||||
const Duration operator - (const Duration &) const;
|
||||
const Duration operator - () const;
|
||||
const Duration operator * (int) const;
|
||||
const Duration operator * (unsigned long long) const;
|
||||
const Duration operator * (float) const;
|
||||
const Duration operator * (double) const;
|
||||
const Duration operator * (long double) const;
|
||||
const Duration operator / (int) const;
|
||||
const Duration operator / (unsigned long long) const;
|
||||
const Duration operator / (float) const;
|
||||
const Duration operator / (double) const;
|
||||
const Duration operator / (long double) const;
|
||||
|
||||
Duration& operator += (const Duration &);
|
||||
Duration& operator -= (const Duration &);
|
||||
|
|
@ -97,16 +97,16 @@ namespace easy2d
|
|||
Duration& operator /= (double);
|
||||
Duration& operator /= (long double);
|
||||
|
||||
friend Duration operator* (int, const Duration &);
|
||||
friend Duration operator* (unsigned long long, const Duration &);
|
||||
friend Duration operator* (float, const Duration &);
|
||||
friend Duration operator* (double, const Duration &);
|
||||
friend Duration operator* (long double, const Duration &);
|
||||
friend Duration operator/ (int, const Duration &);
|
||||
friend Duration operator/ (unsigned long long, const Duration &);
|
||||
friend Duration operator/ (float, const Duration &);
|
||||
friend Duration operator/ (double, const Duration &);
|
||||
friend Duration operator/ (long double, const Duration &);
|
||||
friend const Duration operator* (int, const Duration &);
|
||||
friend const Duration operator* (unsigned long long, const Duration &);
|
||||
friend const Duration operator* (float, const Duration &);
|
||||
friend const Duration operator* (double, const Duration &);
|
||||
friend const Duration operator* (long double, const Duration &);
|
||||
friend const Duration operator/ (int, const Duration &);
|
||||
friend const Duration operator/ (unsigned long long, const Duration &);
|
||||
friend const Duration operator/ (float, const Duration &);
|
||||
friend const Duration operator/ (double, const Duration &);
|
||||
friend const Duration operator/ (long double, const Duration &);
|
||||
|
||||
friend std::wostream& operator<< (std::wostream &, const Duration &);
|
||||
friend std::wistream& operator>> (std::wistream &, Duration &);
|
||||
|
|
@ -161,13 +161,13 @@ namespace easy2d
|
|||
// ÊÇ·ñÊÇÁãʱ
|
||||
bool IsZero() const;
|
||||
|
||||
TimePoint operator + (const Duration &) const;
|
||||
TimePoint operator - (const Duration &) const;
|
||||
const TimePoint operator + (const Duration &) const;
|
||||
const TimePoint operator - (const Duration &) const;
|
||||
|
||||
TimePoint& operator += (const Duration &);
|
||||
TimePoint& operator -= (const Duration &);
|
||||
|
||||
Duration operator - (const TimePoint &) const;
|
||||
const Duration operator - (const TimePoint &) const;
|
||||
|
||||
TimePoint& operator = (const TimePoint &) E2D_NOEXCEPT;
|
||||
TimePoint& operator = (TimePoint &&) E2D_NOEXCEPT;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace easy2d
|
|||
this->_32 = _32;
|
||||
}
|
||||
|
||||
inline Matrix operator*(const Matrix &matrix) const
|
||||
inline const Matrix operator*(const Matrix &matrix) const
|
||||
{
|
||||
return Matrix(
|
||||
_11 * matrix._11 + _12 * matrix._21,
|
||||
|
|
|
|||
|
|
@ -60,27 +60,27 @@ namespace easy2d
|
|||
return Vector2(x - v.x, y - v.y).Length();
|
||||
}
|
||||
|
||||
inline Vector2 operator + (const Vector2 & other) const
|
||||
inline const Vector2 operator + (const Vector2 & other) const
|
||||
{
|
||||
return Vector2(x + other.x, y + other.y);
|
||||
}
|
||||
|
||||
inline Vector2 operator - (const Vector2 & other) const
|
||||
inline const Vector2 operator - (const Vector2 & other) const
|
||||
{
|
||||
return Vector2(x - other.x, y - other.y);
|
||||
}
|
||||
|
||||
inline Vector2 operator * (float val) const
|
||||
inline const Vector2 operator * (float val) const
|
||||
{
|
||||
return Vector2(x * val, y * val);
|
||||
}
|
||||
|
||||
inline Vector2 operator / (float val) const
|
||||
inline const Vector2 operator / (float val) const
|
||||
{
|
||||
return Vector2(x / val, y / val);
|
||||
}
|
||||
|
||||
inline Vector2 operator - () const
|
||||
inline const Vector2 operator - () const
|
||||
{
|
||||
return Vector2(-x, -y);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue