Fix comparisons of char and wchar_t with wxUniChar[Ref].

Comparisons didn't work correctly in the other direction as they were not
reversed as needed. Fix this by adding wxDEFINE_COMPARISON_REV() macro which
defines comparisons in terms of the reverse operations and use it for both
wxUniChar and wxUniCharRef.

Closes #14547.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72268 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-07-31 16:49:36 +00:00
parent d50905f761
commit 6d93e28adf
3 changed files with 70 additions and 11 deletions

View File

@@ -329,17 +329,13 @@ inline wxUniChar& wxUniChar::operator=(const wxUniCharRef& c)
// Comparison operators for the case when wxUniChar(Ref) is the second operand
// implemented in terms of member comparison functions
#define wxCMP_REVERSE(c1, c2, op) c2 op c1
wxDEFINE_COMPARISONS_BY_REV(char, const wxUniChar&)
wxDEFINE_COMPARISONS_BY_REV(char, const wxUniCharRef&)
wxDEFINE_COMPARISONS(char, const wxUniChar&, wxCMP_REVERSE)
wxDEFINE_COMPARISONS(char, const wxUniCharRef&, wxCMP_REVERSE)
wxDEFINE_COMPARISONS_BY_REV(wchar_t, const wxUniChar&)
wxDEFINE_COMPARISONS_BY_REV(wchar_t, const wxUniCharRef&)
wxDEFINE_COMPARISONS(wchar_t, const wxUniChar&, wxCMP_REVERSE)
wxDEFINE_COMPARISONS(wchar_t, const wxUniCharRef&, wxCMP_REVERSE)
wxDEFINE_COMPARISONS(const wxUniChar&, const wxUniCharRef&, wxCMP_REVERSE)
#undef wxCMP_REVERSE
wxDEFINE_COMPARISONS_BY_REV(const wxUniChar&, const wxUniCharRef&)
// for expressions like c-'A':
inline int operator-(char c1, const wxUniCharRef& c2) { return -(c2 - c1); }