diff --git a/include/wx/math.h b/include/wx/math.h index a9cc8df6df..3ae886cc35 100644 --- a/include/wx/math.h +++ b/include/wx/math.h @@ -164,9 +164,21 @@ inline int wxRound(float x) inline int wxRound(long double x) { return wxRound(double(x)); } +// For compatibility purposes, define wxRound() overloads for integer types +// too, as this used to compile with wx 3.0. +#if WXWIN_COMPATIBILITY_3_0 + wxDEPRECATED_MSG("rounding an integer is useless") inline int wxRound(int x) { return x; } +wxDEPRECATED_MSG("rounding an integer is useless") +inline int wxRound(short x) { return x; } + +wxDEPRECATED_MSG("rounding an integer is useless") +inline int wxRound(long x) { return static_cast(x); } + +#endif // WXWIN_COMPATIBILITY_3_0 + // Convert between degrees and radians. inline double wxDegToRad(double deg) { return (deg * M_PI) / 180.0; } inline double wxRadToDeg(double rad) { return (rad * 180.0) / M_PI; } diff --git a/interface/wx/math.h b/interface/wx/math.h index 5774680131..5e0b6e3d2c 100644 --- a/interface/wx/math.h +++ b/interface/wx/math.h @@ -89,9 +89,18 @@ double wxRadToDeg(double rad); unsigned int wxCTZ(wxUint32 x); /** - Small wrapper around round(). + Small wrapper around std::lround(). + + This function exists for compatibility, as it was more convenient than + std::round() before C++11. Use std::lround() in the new code. + + It is defined for all floating point types @c T and can be also used with + integer types for compatibility, but such use is deprecated -- simply + remove the calls to wxRound() from your code if you're using it with + integer types, it is unnecessary in this case. */ -int wxRound(double x); +template +int wxRound(T x); /** Returns true if both double values are identical. This is