diff --git a/src/OpenFOAM/containers/NamedEnum/NamedEnum.C b/src/OpenFOAM/containers/NamedEnum/NamedEnum.C index 17f5a246a1675104c0c947c8fed5e8b099a28d06..89784a1400b731514148fcb57d313b9e3bd92c00 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 4a8351ad84684478e6347fac0f55583335964f49..dc85f279f07a53d1ae33313a83360f5ad97a8f1b 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 c6e668e41dafb18a62a25a7d08b62c4794c2baf7..03be3b7305e218ced42354fbefaff9a4dd0bbe85 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 48d14b9e3f345d2f0d0b276b40dd4a5d21ca0c22..82878d2278a7054ee1e7d801978d5899347d46f0 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 0ff615f1c276cca2099d9acc491004e093dbb0e0..4a450b5a6a756d255c7303d7171b90833ac85c6f 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 c910527123e69a2ec916bffe23d996d31eae6723..0e7509c684ceba7c117aec9d5c4df5a32871f856 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 f15c901b122d198e6bdcc1575ebd08acc9edaa5a..f373186a548eb71cd183fdbb587bd9425d232b92 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 d5d5b045124568370cba32c749cb590127a849c9..22cc06d05c6e8653ec7cdcbf3f308e2110e62097 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 762ef89ee1764e624eeffcb7122403aea6298ad6..2d83def92090a598a8b38213dc82f79a0c2b301e 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 cdb5f0e59ade9c5989c6dd9d046eb4a9fb4bcc3f..b45193f0e730b3d59ede32f0f443bf62b252046a 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 0e0c72af77c9836d9c175c22a297dc3063be0b4e..861be7665ae56edbff050e0dd13b687adfac06cf 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 840e28b7f697743c3dcf5120a469297d56226931..e0e586673acd317ba968050ae2d270137d6f2dfd 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 e6e2fe8c34d49f8688929d985f3354a7ebdd9f0a..69d2a4033b8607c32d13a876b3670a9effb0763c 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 a7a716eb7f72d3e2288b3d7c59d6f86b1d9b6419..dd8a081b6dfa49907d0691be857d30affe042919 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 a5ad75c2134b2d29e321f80db267b2ca0ef21261..05ef84af2c5d02259360169c0528deaf47ffdd42 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 a6e1d59d0272ea3ce8890460cc102bd3283a9dff..91973a5d6b6d5b6723869459cd77d3bc9680e3c6 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 462c318755e603b05282db2e6829a5e63d60ac6b..072e76511090a5656e6c197d927b6f7530e2d34b 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 7c27f9fc264a82df9221ea870e62d74552cf80b8..adcac28e03554c28a30612ad62e1e745156d7e88 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 750a6737ff6b08bc888fa333326b0d08c63d23c4..ea6cc3328a31f652ab14c1b2e31ee361860b5bbc 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 1a9ab62fc816f587701c473e9812732b6407e951..a78397a35849230aea591f0e14f657dff2d8cadd 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; }