From f7e502d459232ca0ea99653e3a15961d61bb1439 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Thu, 4 May 2017 02:39:57 +0200
Subject: [PATCH] STYLE: relocate some friend operations to be global ones

---
 src/OpenFOAM/containers/NamedEnum/NamedEnum.C |  2 +-
 src/OpenFOAM/meshes/boundBox/boundBox.H       | 18 ++++-----
 src/OpenFOAM/meshes/boundBox/boundBoxI.H      |  4 +-
 src/OpenFOAM/meshes/meshShapes/cell/cellI.H   |  2 +-
 .../meshes/meshShapes/cellModel/cellModel.H   |  6 +--
 .../meshes/meshShapes/cellModel/cellModelI.H  | 37 ++++++++-----------
 src/OpenFOAM/meshes/meshShapes/edge/edge.H    | 27 ++++++--------
 src/OpenFOAM/meshes/meshShapes/edge/edgeI.H   |  2 +-
 src/OpenFOAM/meshes/meshShapes/face/face.H    | 13 +++----
 src/OpenFOAM/meshes/meshShapes/face/faceI.H   |  4 +-
 .../meshShapes/labelledTri/labelledTriI.H     |  3 +-
 .../meshes/meshShapes/triFace/triFace.H       | 15 ++++----
 .../meshes/meshShapes/triFace/triFaceI.H      |  2 +-
 .../primitiveShapes/objectHit/objectHit.H     | 31 ++++++++--------
 .../meshes/primitiveShapes/plane/plane.C      |  6 +--
 .../meshes/primitiveShapes/plane/plane.H      | 16 ++++----
 .../meshes/treeBoundBox/treeBoundBox.C        | 18 ---------
 .../meshes/treeBoundBox/treeBoundBox.H        | 16 +++-----
 .../meshes/treeBoundBox/treeBoundBoxI.H       | 13 +++++++
 src/OpenFOAM/primitives/Pair/Pair.H           | 22 ++++++-----
 20 files changed, 117 insertions(+), 140 deletions(-)

diff --git a/src/OpenFOAM/containers/NamedEnum/NamedEnum.C b/src/OpenFOAM/containers/NamedEnum/NamedEnum.C
index 17f5a246a16..89784a1400b 100644
--- a/src/OpenFOAM/containers/NamedEnum/NamedEnum.C
+++ b/src/OpenFOAM/containers/NamedEnum/NamedEnum.C
@@ -71,7 +71,7 @@ Enum Foam::NamedEnum<Enum, nEnum>::read(Istream& is) const
             << sortedToc() << exit(FatalIOError);
     }
 
-    return Enum(*iter);
+    return Enum(iter.object());
 }
 
 
diff --git a/src/OpenFOAM/meshes/boundBox/boundBox.H b/src/OpenFOAM/meshes/boundBox/boundBox.H
index 4a8351ad846..dc85f279f07 100644
--- a/src/OpenFOAM/meshes/boundBox/boundBox.H
+++ b/src/OpenFOAM/meshes/boundBox/boundBox.H
@@ -50,11 +50,8 @@ namespace Foam
 class boundBox;
 template<class T> class tmp;
 
-bool operator==(const boundBox&, const boundBox&);
-bool operator!=(const boundBox&, const boundBox&);
-
-Istream& operator>>(Istream&, boundBox&);
-Ostream& operator<<(Ostream&, const boundBox&);
+Istream& operator>>(Istream& is, boundBox& bb);
+Ostream& operator<<(Ostream& os, const boundBox& bb);
 
 
 /*---------------------------------------------------------------------------*\
@@ -289,12 +286,6 @@ public:
         inline void operator+=(const boundBox& bb);
 
 
-    // Friend Operators
-
-        inline friend bool operator==(const boundBox& a, const boundBox& b);
-        inline friend bool operator!=(const boundBox& a, const boundBox& b);
-
-
     // IOstream operator
 
         friend Istream& operator>>(Istream& is, boundBox& bb);
@@ -306,6 +297,11 @@ public:
 template<>
 inline bool contiguous<boundBox>() {return contiguous<point>();}
 
+// Global Operators
+
+inline bool operator==(const boundBox& a, const boundBox& b);
+inline bool operator!=(const boundBox& a, const boundBox& b);
+
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/src/OpenFOAM/meshes/boundBox/boundBoxI.H b/src/OpenFOAM/meshes/boundBox/boundBoxI.H
index c6e668e41da..03be3b7305e 100644
--- a/src/OpenFOAM/meshes/boundBox/boundBoxI.H
+++ b/src/OpenFOAM/meshes/boundBox/boundBoxI.H
@@ -268,11 +268,11 @@ inline void Foam::boundBox::operator+=(const boundBox& bb)
 }
 
 
-// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
+// * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * * //
 
 inline bool Foam::operator==(const boundBox& a, const boundBox& b)
 {
-    return (a.min_ == b.min_) && (a.max_ == b.max_);
+    return (a.min() == b.min()) && (a.max() == b.max());
 }
 
 
diff --git a/src/OpenFOAM/meshes/meshShapes/cell/cellI.H b/src/OpenFOAM/meshes/meshShapes/cell/cellI.H
index 48d14b9e3f3..82878d2278a 100644
--- a/src/OpenFOAM/meshes/meshShapes/cell/cellI.H
+++ b/src/OpenFOAM/meshes/meshShapes/cell/cellI.H
@@ -63,7 +63,7 @@ inline Foam::label Foam::cell::nFaces() const
 
 inline bool Foam::operator!=(const cell& a, const cell& b)
 {
-    return (!(a == b));
+    return !(a == b);
 }
 
 
diff --git a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.H b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.H
index 0ff615f1c27..4a450b5a6a7 100644
--- a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.H
+++ b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.H
@@ -59,7 +59,7 @@ Ostream& operator<<(Ostream& os, const cellModel& c);
 
 
 /*---------------------------------------------------------------------------*\
-                           Class cellModel Declaration
+                          Class cellModel Declaration
 \*---------------------------------------------------------------------------*/
 
 class cellModel
@@ -122,13 +122,13 @@ public:
             inline label nFaces() const;
 
             //- Return list of edges
-            inline edgeList edges(const labelList& pointLabels) const;
+            inline edgeList edges(const UList<label>& pointLabels) const;
 
             //- Return a raw list of model faces
             inline const faceList& modelFaces() const;
 
             //- Return list of faces
-            inline faceList faces(const labelList& pointLabels) const;
+            inline faceList faces(const UList<label>& pointLabels) const;
 
 
         //- Vector centroid
diff --git a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModelI.H b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModelI.H
index c910527123e..0e7509c684c 100644
--- a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModelI.H
+++ b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModelI.H
@@ -21,45 +21,38 @@ License
     You should have received a copy of the GNU General Public License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
-Description
-
 \*---------------------------------------------------------------------------*/
 
 #include "error.H"
 #include "cellModel.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-inline const word& cellModel::name() const
+inline const Foam::word& Foam::cellModel::name() const
 {
     return name_;
 }
 
 
-inline label cellModel::index() const
+inline Foam::label Foam::cellModel::index() const
 {
     return index_;
 }
 
 
-inline label cellModel::nPoints() const
+inline Foam::label Foam::cellModel::nPoints() const
 {
     return nPoints_;
 }
 
 
-inline label cellModel::nEdges() const
+inline Foam::label Foam::cellModel::nEdges() const
 {
     return edges_.size();
 }
 
 
-inline label cellModel::nFaces() const
+inline Foam::label Foam::cellModel::nFaces() const
 {
     return faces_.size();
 }
@@ -67,7 +60,10 @@ inline label cellModel::nFaces() const
 
 //  Return the faces of a cellModel by untangling the geometry
 //  supplied in terms of the face labels
-inline edgeList cellModel::edges(const labelList& pointLabels) const
+inline Foam::edgeList Foam::cellModel::edges
+(
+    const UList<label>& pointLabels
+) const
 {
     edgeList e(edges_.size());
 
@@ -86,7 +82,7 @@ inline edgeList cellModel::edges(const labelList& pointLabels) const
 }
 
 
-inline const faceList& cellModel::modelFaces() const
+inline const Foam::faceList& Foam::cellModel::modelFaces() const
 {
     return faces_;
 }
@@ -94,7 +90,10 @@ inline const faceList& cellModel::modelFaces() const
 
 //  Return the faces of a cellModel by untangling the geometry
 //  supplied in terms of the face labels
-inline faceList cellModel::faces(const labelList& pointLabels) const
+inline Foam::faceList Foam::cellModel::faces
+(
+    const UList<label>& pointLabels
+) const
 {
     faceList f(faces_.size());
 
@@ -120,20 +119,16 @@ inline faceList cellModel::faces(const labelList& pointLabels) const
 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
 
 // Equality operator: true => ptr to models are equal !
-inline bool operator==(const cellModel& m1, const cellModel& m2)
+inline bool Foam::operator==(const cellModel& m1, const cellModel& m2)
 {
     return (&m1 == &m2);
 }
 
 // Inequality operator: true => ptr to models are not equal !
-inline bool operator!=(const cellModel& m1, const cellModel& m2)
+inline bool Foam::operator!=(const cellModel& m1, const cellModel& m2)
 {
     return (&m1 != &m2);
 }
 
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edge.H b/src/OpenFOAM/meshes/meshShapes/edge/edge.H
index f15c901b122..f373186a548 100644
--- a/src/OpenFOAM/meshes/meshShapes/edge/edge.H
+++ b/src/OpenFOAM/meshes/meshShapes/edge/edge.H
@@ -34,7 +34,7 @@ Description
     Valid point labels are always non-negative (since they correspond to
     addressing within the mesh). The value '-1' is used to tag invalid
     point labels that correspond conceptually to open 'slots', which
-    can be filled with the HashSet-like functionality.
+    can be filled with a HashSet-like functionality.
 
 SourceFiles
     edgeI.H
@@ -53,15 +53,8 @@ SourceFiles
 namespace Foam
 {
 
-// Forward declaration of friend functions and operators
-
-class edge;
-inline bool operator==(const edge& a, const edge& b);
-inline bool operator!=(const edge& a, const edge& b);
-
-
 /*---------------------------------------------------------------------------*\
-                           Class edge Declaration
+                            Class edge Declaration
 \*---------------------------------------------------------------------------*/
 
 class edge
@@ -266,16 +259,20 @@ public:
         //- Compare edges
         //  Returns:
         //  -  0: different
-        //  - +1: identical
-        //  - -1: same edge, but different orientation
+        //  - +1: identical values and order used
+        //  - -1: identical values, but in different order
         static inline int compare(const edge& a, const edge& b);
 
+};
 
-    // Friend Operators
 
-        friend bool operator==(const edge& a, const edge& b);
-        friend bool operator!=(const edge& a, const edge& b);
-};
+// Global Operators
+
+//- Compare edges for equal content, ignoring orientation
+inline bool operator==(const edge& a, const edge& b);
+
+//- Compare edges for non-equal content, ignoring orientation
+inline bool operator!=(const edge& a, const edge& b);
 
 
 //- Hash specialization for hashing edges - a commutative hash value.
diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H b/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H
index d5d5b045124..22cc06d05c6 100644
--- a/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H
+++ b/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H
@@ -451,7 +451,7 @@ inline Foam::linePointRef Foam::edge::line(const UList<point>& pts) const
 }
 
 
-// * * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * //
+// * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * * //
 
 inline bool Foam::operator==(const edge& a, const edge& b)
 {
diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H
index 762ef89ee17..2d83def9209 100644
--- a/src/OpenFOAM/meshes/meshShapes/face/face.H
+++ b/src/OpenFOAM/meshes/meshShapes/face/face.H
@@ -65,8 +65,6 @@ class triFace;
 template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
 class DynamicList;
 
-inline bool operator==(const face& a, const face& b);
-inline bool operator!=(const face& a, const face& b);
 inline Istream& operator>>(Istream& is, face& f);
 
 /*---------------------------------------------------------------------------*\
@@ -382,12 +380,6 @@ public:
         static bool sameVertices(const face& a, const face& b);
 
 
-    // Friend Operators
-
-        friend bool operator==(const face& a, const face& b);
-        friend bool operator!=(const face& a, const face& b);
-
-
     // Istream Operator
 
         friend Istream& operator>>(Istream& is, face& f);
@@ -418,6 +410,11 @@ public:
 };
 
 
+// Global operators
+inline bool operator==(const face& a, const face& b);
+inline bool operator!=(const face& a, const face& b);
+
+
 // Global functions
 
 //- Find the longest edge on a face. Face point labels index into pts.
diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceI.H b/src/OpenFOAM/meshes/meshShapes/face/faceI.H
index cdb5f0e59ad..b45193f0e73 100644
--- a/src/OpenFOAM/meshes/meshShapes/face/faceI.H
+++ b/src/OpenFOAM/meshes/meshShapes/face/faceI.H
@@ -135,14 +135,14 @@ inline Foam::label Foam::face::nTriangles() const
     return size() - 2;
 }
 
-// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
+
+// * * * * * * * * * * * * * * * Global Operators   * * * * * * * * * * * * * //
 
 inline bool Foam::operator==(const face& a, const face& b)
 {
     return face::compare(a,b) != 0;
 }
 
-
 inline bool Foam::operator!=(const face& a, const face& b)
 {
     return face::compare(a,b) == 0;
diff --git a/src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTriI.H b/src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTriI.H
index 0e0c72af77c..861be7665ae 100644
--- a/src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTriI.H
+++ b/src/OpenFOAM/meshes/meshShapes/labelledTri/labelledTriI.H
@@ -162,8 +162,7 @@ inline Foam::Ostream& Foam::operator<<(Ostream& os, const labelledTri& t)
     }
 
     // Check state of Ostream
-    os.check("Ostream& operator<<(Ostream&, const labelledTri&)");
-
+    os.check(FUNCTION_NAME);
 
     return os;
 }
diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H
index 840e28b7f69..e0e586673ac 100644
--- a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H
+++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H
@@ -229,13 +229,16 @@ public:
         //  - -1: same face, but different orientation
         static inline int compare(const triFace& a, const triFace& b);
 
-    // Friend Operators
-
-        inline friend bool operator==(const triFace& a, const triFace& b);
-        inline friend bool operator!=(const triFace& a, const triFace& b);
 };
 
 
+template<>
+inline bool contiguous<triFace>()  {return true;}
+
+inline bool operator==(const triFace& a, const triFace& b);
+inline bool operator!=(const triFace& a, const triFace& b);
+
+
 //- Hash specialization for hashing triFace - a commutative hash value.
 //  Hash incrementally.
 template<>
@@ -260,10 +263,6 @@ inline unsigned Hash<triFace>::operator()(const triFace& t) const
 }
 
 
-template<>
-inline bool contiguous<triFace>()  {return true;}
-
-
 //- Hash specialization to offset faces in ListListOps::combineOffset
 template<>
 class offsetOp<triFace>
diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H
index e6e2fe8c34d..69d2a4033b8 100644
--- a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H
+++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H
@@ -377,7 +377,7 @@ inline int Foam::triFace::edgeDirection(const edge& e) const
 }
 
 
-// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
+// * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
 
 inline bool Foam::operator==(const triFace& a, const triFace& b)
 {
diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H
index a7a716eb7f7..dd8a081b6df 100644
--- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H
+++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H
@@ -84,31 +84,18 @@ public:
     // Member Functions
 
         //- Is there a hit
-        bool hit() const
+        inline bool hit() const
         {
             return hit_;
         }
 
         //- Return hit object
-        label hitObject() const
+        inline label hitObject() const
         {
             return hitObject_;
         }
 
 
-    // Friend Operators
-
-        inline friend bool operator==(const objectHit& a, const objectHit& b)
-        {
-            return (a.hit_ == b.hit_) && (a.hitObject_ == b.hitObject_);
-        }
-
-        inline friend bool operator!=(const objectHit& a, const objectHit& b)
-        {
-            return !(a == b);
-        }
-
-
     // Ostream operator
 
         inline friend Ostream& operator<<(Ostream& os, const objectHit& obj)
@@ -118,6 +105,20 @@ public:
 };
 
 
+// Global Operators
+
+inline bool operator==(const objectHit& a, const objectHit& b)
+{
+    return a.hit() == b.hit() && a.hitObject() == b.hitObject();
+}
+
+
+inline bool operator!=(const objectHit& a, const objectHit& b)
+{
+    return !(a == b);
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C b/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C
index a5ad75c2134..05ef84af2c5 100644
--- a/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C
+++ b/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C
@@ -487,14 +487,14 @@ void Foam::plane::writeDict(Ostream& os) const
     os.endBlock() << flush;
 }
 
-
-// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
+// * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
 
 bool Foam::operator==(const plane& a, const plane& b)
 {
-    return (a.point_ == b.point_ && a.normal_ == b.normal_);
+    return (a.refPoint() == b.refPoint() && a.normal() == b.normal());
 }
 
+
 bool Foam::operator!=(const plane& a, const plane& b)
 {
     return !(a == b);
diff --git a/src/OpenFOAM/meshes/primitiveShapes/plane/plane.H b/src/OpenFOAM/meshes/primitiveShapes/plane/plane.H
index a6e1d59d027..91973a5d6b6 100644
--- a/src/OpenFOAM/meshes/primitiveShapes/plane/plane.H
+++ b/src/OpenFOAM/meshes/primitiveShapes/plane/plane.H
@@ -49,8 +49,6 @@ namespace Foam
 // Forward declaration of friend functions and operators
 
 class plane;
-bool operator==(const plane& a, const plane& b);
-bool operator!=(const plane& a, const plane& b);
 Ostream& operator<<(Ostream& os, const plane& pln);
 
 
@@ -193,7 +191,7 @@ public:
 
         //- Return the cutting line between this plane and another.
         //  Returned as direction vector and point line goes through.
-        ray planeIntersect(const plane&) const;
+        ray planeIntersect(const plane& plane2) const;
 
         //- Return the cutting point between this plane and two other planes
         point planePlaneIntersect
@@ -217,12 +215,6 @@ public:
         void writeDict(Ostream& os) const;
 
 
-    // friend Operators
-
-        friend bool operator==(const plane& a, const plane& b);
-        friend bool operator!=(const plane& a, const plane& b);
-
-
     // IOstream Operators
 
         //- Write plane properties
@@ -231,6 +223,12 @@ public:
 };
 
 
+// Global Operators
+
+bool operator==(const plane& a, const plane& b);
+bool operator!=(const plane& a, const plane& b);
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.C b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.C
index 462c318755e..072e7651109 100644
--- a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.C
+++ b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.C
@@ -555,24 +555,6 @@ Foam::label Foam::treeBoundBox::distanceCmp
 }
 
 
-// * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
-
-bool Foam::operator==(const treeBoundBox& a, const treeBoundBox& b)
-{
-    return operator==
-    (
-        static_cast<const boundBox&>(a),
-        static_cast<const boundBox&>(b)
-    );
-}
-
-
-bool Foam::operator!=(const treeBoundBox& a, const treeBoundBox& b)
-{
-    return !(a == b);
-}
-
-
 // * * * * * * * * * * * * * * * Ostream Operator  * * * * * * * * * * * * * //
 
 Foam::Ostream& Foam::operator<<(Ostream& os, const treeBoundBox& bb)
diff --git a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.H b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.H
index 7c27f9fc264..adcac28e035 100644
--- a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.H
+++ b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.H
@@ -77,10 +77,6 @@ class Random;
 // Forward declaration of friend functions and operators
 
 class treeBoundBox;
-
-bool operator==(const treeBoundBox& a, const treeBoundBox& b);
-bool operator!=(const treeBoundBox& a, const treeBoundBox& b);
-
 Istream& operator>>(Istream& is, treeBoundBox& bb);
 Ostream& operator<<(Ostream& os, const treeBoundBox& bb);
 
@@ -340,12 +336,6 @@ public:
             inline treeBoundBox extend(Random& rndGen, const scalar s) const;
 
 
-    // Friend Operators
-
-        friend bool operator==(const treeBoundBox& a, const treeBoundBox& b);
-        friend bool operator!=(const treeBoundBox& a, const treeBoundBox& b);
-
-
     // IOstream operator
 
         friend Istream& operator>>(Istream& is, treeBoundBox& bb);
@@ -358,6 +348,12 @@ template<>
 inline bool contiguous<treeBoundBox>() {return contiguous<boundBox>();}
 
 
+// Global Operators
+
+inline bool operator==(const treeBoundBox& a, const treeBoundBox& b);
+inline bool operator!=(const treeBoundBox& a, const treeBoundBox& b);
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
diff --git a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxI.H b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxI.H
index 750a6737ff6..ea6cc3328a3 100644
--- a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxI.H
+++ b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxI.H
@@ -343,4 +343,17 @@ inline Foam::treeBoundBox Foam::treeBoundBox::extend
 }
 
 
+// * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * * //
+
+inline bool Foam::operator==(const treeBoundBox& a, const treeBoundBox& b)
+{
+    return static_cast<const boundBox&>(a) == static_cast<const boundBox&>(b);
+}
+
+
+inline bool Foam::operator!=(const treeBoundBox& a, const treeBoundBox& b)
+{
+    return !(a == b);
+}
+
 // ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/Pair/Pair.H b/src/OpenFOAM/primitives/Pair/Pair.H
index 1a9ab62fc81..a78397a3584 100644
--- a/src/OpenFOAM/primitives/Pair/Pair.H
+++ b/src/OpenFOAM/primitives/Pair/Pair.H
@@ -70,9 +70,9 @@ public:
         }
 
         //- Construct from FixedList
-        inline Pair(const FixedList<Type, 2>& fl)
+        inline Pair(const FixedList<Type, 2>& lst)
         :
-            FixedList<Type, 2>(fl)
+            FixedList<Type, 2>(lst)
         {}
 
         //- Construct from Istream
@@ -134,18 +134,20 @@ public:
         }
 
 
+     // Comparison
+
         //- Compare Pairs
-        //  Returning:
+        //  Returns:
         //  -  0: different
-        //  - +1: identical
-        //  - -1: same pair, but reversed order
+        //  - +1: identical values and order used
+        //  - -1: identical values, but in reversed order
         static inline int compare(const Pair<Type>& a, const Pair<Type>& b)
         {
-            if (a == b)
+            if (a[0] == b[0] && a[1] == b[1])
             {
                 return 1;
             }
-            else if (a == reverse(b))
+            else if (a[0] == b[1] && a[1] == b[0])
             {
                 return -1;
             }
@@ -157,6 +159,8 @@ public:
 };
 
 
+// * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * * //
+
 template<class Type>
 Pair<Type> reverse(const Pair<Type>& p)
 {
@@ -167,14 +171,14 @@ Pair<Type> reverse(const Pair<Type>& p)
 template<class Type>
 bool operator==(const Pair<Type>& a, const Pair<Type>& b)
 {
-    return (a.first() == b.first() && a.second() == b.second());
+    return Pair<Type>::compare(a,b) != 0;
 }
 
 
 template<class Type>
 bool operator!=(const Pair<Type>& a, const Pair<Type>& b)
 {
-    return !(a == b);
+    return Pair<Type>::compare(a,b) == 0;
 }
 
 
-- 
GitLab