Make wxTimeSpan::operator-() const

Due to an oversight, it wasn't declared as const, making it impossible to
subtract from a const wxTimeSpan object.

Fix this and add a unit test verifying that this compiles and works as
expected.

Closes #17583.
This commit is contained in:
Vadim Zeitlin
2016-06-30 16:49:20 +02:00
parent 9bf97bd607
commit ffcdcc1617
3 changed files with 16 additions and 1 deletions

View File

@@ -1210,7 +1210,7 @@ public:
inline wxTimeSpan& Subtract(const wxTimeSpan& diff);
// subtract another timespan
wxTimeSpan& operator-=(const wxTimeSpan& diff) { return Subtract(diff); }
inline wxTimeSpan operator-(const wxTimeSpan& ts)
inline wxTimeSpan operator-(const wxTimeSpan& ts) const
{
return wxTimeSpan(GetValue() - ts.GetValue());
}