diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2023-08-02 12:25:09 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2023-08-02 14:11:56 +0200 |
commit | 4a3da80a9eb1a95a4cd3c8a98a37d480d7a29bba (patch) | |
tree | 41e1922bd5040abdc115d08ff592d5240f992707 /include/tools/gen.hxx | |
parent | f151ba5ebc8662d5459eacb1c5d6f01a4c826f26 (diff) |
Make RectangleTemplate comparison operators symmetric
...to avoid
> In file included from tools/qa/cppunit/test_rectangle.cxx:10:
> workdir/UnpackedTarball/cppunit/include/cppunit/TestAssert.h:59:18: error: ISO C++20 considers use of overloaded operator '==' (with operand types 'const tools::Rectangle' and 'const tools::Rectangle') to be ambiguous despite there being a unique best viable function [-Werror,-Wambiguous-reversed-operator]
> return x == y;
> ~ ^ ~
> workdir/UnpackedTarball/cppunit/include/cppunit/TestAssert.h:166:30: note: in instantiation of member function 'CppUnit::assertion_traits<tools::Rectangle>::equal' requested here
> if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
> ^
> tools/qa/cppunit/test_rectangle.cxx:70:9: note: in instantiation of function template specialization 'CppUnit::assertEquals<tools::Rectangle>' requested here
> CPPUNIT_ASSERT_EQUAL(aRect, aRect2);
> ^
> workdir/UnpackedTarball/cppunit/include/cppunit/TestAssert.h:333:17: note: expanded from macro 'CPPUNIT_ASSERT_EQUAL'
> ( CPPUNIT_NS::assertEquals( (expected), \
> ^
> include/tools/gen.hxx:817:18: note: ambiguity is between a regular call to this operator and a call with the argument order reversed
> bool operator == ( const RectangleT& rRect ) const
> ^
when building with -std=c++20 (cf.
<https://gerrit.libreoffice.org/c/core/+/155121> "Bump baseline to C++20")
against at least Xcode 14.3.1.
It was presumably an accidental oversight that
b6b26421a1029b18b48b69dbdac4bb70fb622604 "split Point/Size/Rectangle into
AbsoluteScreenPixel* types" made these operators asymmetric in the first place.
Change-Id: Ic1f08b79fbd727d972ce95c3f21eab3a2a74f942
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155221
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/tools/gen.hxx')
-rw-r--r-- | include/tools/gen.hxx | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx index 0555889e0cb2..246d7913cb4e 100644 --- a/include/tools/gen.hxx +++ b/include/tools/gen.hxx @@ -814,14 +814,14 @@ public: bool Contains( const RectangleT& rRect ) const { return RectangleTemplateBase::Contains(rRect); } bool Overlaps( const RectangleT& rRect ) const { return RectangleTemplateBase::Overlaps(rRect); } - bool operator == ( const RectangleT& rRect ) const + bool operator == ( const RectangleTemplate& rRect ) const { return (mnLeft == rRect.mnLeft ) && (mnTop == rRect.mnTop ) && (mnRight == rRect.mnRight ) && (mnBottom == rRect.mnBottom ); } - bool operator != ( const RectangleT& rRect ) const + bool operator != ( const RectangleTemplate& rRect ) const { return (mnLeft != rRect.mnLeft ) || (mnTop != rRect.mnTop ) || |