blob: c7bfb1e40aa2981d17e533086586eba36645f489 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
From 555b3e0c18ba16843541867d036da782ecdcdeb1 Mon Sep 17 00:00:00 2001
From: Stephan Bergmann <sbergman@redhat.com>
Date: Mon, 21 Oct 2019 16:19:13 +0200
Subject: [PATCH] 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 when building libwps as part of LibreOffice:
> QuattroDosChart.cpp:399:18: error: use of overloaded operator '!=' is ambiguous (with operand types 'WKSChart::Position' and 'WKSChart::Position')
> if (ranges[0]!=ranges[1])
> ~~~~~~~~~^ ~~~~~~~~~
> ./WKSChart.h:78:8: note: candidate function
> bool operator!=(Position &pos) const
> ^
> ./WKSChart.h:73:8: note: candidate function
> bool operator==(Position &pos) const
> ^
> ./WKSChart.h:73:8: note: candidate function (with reversed parameter order)
)
---
src/lib/WKSChart.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lib/WKSChart.h b/src/lib/WKSChart.h
index 268fa4a..e490357 100644
--- a/src/lib/WKSChart.h
+++ b/src/lib/WKSChart.h
@@ -70,12 +70,12 @@ public:
//! operator<<
friend std::ostream &operator<<(std::ostream &o, Position const &pos);
//! operator==
- bool operator==(Position &pos) const
+ bool operator==(Position const &pos) const
{
return m_pos==pos.m_pos && m_sheetName==pos.m_sheetName;
}
//! operator!=
- bool operator!=(Position &pos) const
+ bool operator!=(Position const &pos) const
{
return !(operator==(pos));
}
--
2.21.0
|