diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-10-22 23:24:12 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-10-23 07:09:57 +0200 |
commit | 437dc68285dab0f08a1ded2193d86d64f560cd9b (patch) | |
tree | be07be10e2d5e19e3a1ff42911e458f1c571b643 | |
parent | 3ed56f407235feb97ee2565a613e5f1d2bb2d925 (diff) |
Make comparison operator member functions const
...which avoids overload resolution ambiguities in C++20, when a synthesized
candidate of operator == for a reversed-argument rewrite conflicts with the
actual operator ==, due to the asymmetric const-ness of the implicit object
parameter and the RHS parameter. (As observed with recent Clang 10 trunk with
-std=c++2a:
> vcl/unx/generic/gdi/salgdi.cxx:138:18: error: use of overloaded operator '!=' is ambiguous (with operand types 'SalX11Screen' and 'SalX11Screen')
> if( nXScreen != m_nXScreen )
> ~~~~~~~~ ^ ~~~~~~~~~~
> vcl/inc/unx/saltype.h:22:10: note: candidate function
> bool operator!=(const SalX11Screen &rOther) { return rOther.mnXScreen != mnXScreen; }
> ^
> vcl/inc/unx/saltype.h:21:10: note: candidate function
> bool operator==(const SalX11Screen &rOther) { return rOther.mnXScreen == mnXScreen; }
> ^
> vcl/inc/unx/saltype.h:21:10: note: candidate function (with reversed parameter order)
)
Change-Id: I5dab4fecfbb7badab06ebd0d779527de9672a02a
Reviewed-on: https://gerrit.libreoffice.org/81352
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r-- | vcl/inc/unx/saltype.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/vcl/inc/unx/saltype.h b/vcl/inc/unx/saltype.h index 97d9f1a4bb93..e62bdd25e1e2 100644 --- a/vcl/inc/unx/saltype.h +++ b/vcl/inc/unx/saltype.h @@ -18,8 +18,8 @@ class SalX11Screen { public: explicit SalX11Screen(unsigned int nXScreen) : mnXScreen( nXScreen ) {} unsigned int getXScreen() const { return mnXScreen; } - bool operator==(const SalX11Screen &rOther) { return rOther.mnXScreen == mnXScreen; } - bool operator!=(const SalX11Screen &rOther) { return rOther.mnXScreen != mnXScreen; } + bool operator==(const SalX11Screen &rOther) const { return rOther.mnXScreen == mnXScreen; } + bool operator!=(const SalX11Screen &rOther) const { return rOther.mnXScreen != mnXScreen; } }; #endif // INCLUDED_VCL_INC_UNX_SALTYPE_H |