summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-10-21 22:12:06 +0200
committerStephan Bergmann <sbergman@redhat.com>2019-10-22 07:19:03 +0200
commit41147e20029c80c4941ca81bc5dca3782bef5d94 (patch)
tree77de4c4151fe8523635c35b1cbbd01f60a25c227 /sd
parent20c6dfde1dff22de7d38ecea00bcf75aa21a1694 (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: > sd/source/ui/view/Outliner.cxx:543:44: error: use of overloaded operator '!=' is ambiguous (with operand types '::sd::outliner::Iterator' and 'sd::outliner::Iterator') > mbMatchMayExist = (maObjectIterator!=sd::outliner::OutlinerContainer(this).begin()); > ~~~~~~~~~~~~~~~~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > sd/inc/OutlinerIterator.hxx:133:10: note: candidate function > bool operator!= (const Iterator& rIterator); > ^ > sd/inc/OutlinerIterator.hxx:125:10: note: candidate function > bool operator== (const Iterator& rIterator); > ^ > sd/inc/OutlinerIterator.hxx:125:10: note: candidate function (with reversed parameter order) ) Change-Id: Ia477f3f9cf19a5ae0e15a4536d70924962098ce4 Reviewed-on: https://gerrit.libreoffice.org/81280 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/inc/OutlinerIterator.hxx4
-rw-r--r--sd/source/ui/view/OutlinerIterator.cxx4
2 files changed, 4 insertions, 4 deletions
diff --git a/sd/inc/OutlinerIterator.hxx b/sd/inc/OutlinerIterator.hxx
index dcc8238d4271..e78e9447d506 100644
--- a/sd/inc/OutlinerIterator.hxx
+++ b/sd/inc/OutlinerIterator.hxx
@@ -122,7 +122,7 @@ public:
@return
Returns <TRUE/> when both iterators point to the same object.
*/
- bool operator== (const Iterator& rIterator);
+ bool operator== (const Iterator& rIterator) const;
/** Test whether two iterators point to different objects. This is just
the negation of the result of the equality operator.
@param rIterator
@@ -130,7 +130,7 @@ public:
@return
Returns <TRUE/> when both iterators point to the different objects.
*/
- bool operator!= (const Iterator& rIterator);
+ bool operator!= (const Iterator& rIterator) const;
/** Reverse the direction of iteration. The position of the iterator is
not changed. Thus calling this method twice returns to the old state.
*/
diff --git a/sd/source/ui/view/OutlinerIterator.cxx b/sd/source/ui/view/OutlinerIterator.cxx
index aa7bb51b1184..b91e6de9640c 100644
--- a/sd/source/ui/view/OutlinerIterator.cxx
+++ b/sd/source/ui/view/OutlinerIterator.cxx
@@ -104,7 +104,7 @@ Iterator& Iterator::operator++ ()
return *this;
}
-bool Iterator::operator== (const Iterator& rIterator)
+bool Iterator::operator== (const Iterator& rIterator) const
{
if (!mxIterator || !rIterator.mxIterator)
return mxIterator.get() == rIterator.mxIterator.get();
@@ -112,7 +112,7 @@ bool Iterator::operator== (const Iterator& rIterator)
return *mxIterator == *rIterator.mxIterator;
}
-bool Iterator::operator!= (const Iterator& rIterator)
+bool Iterator::operator!= (const Iterator& rIterator) const
{
return ! operator==(rIterator);
}