diff --git a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h index 491f2747353..0b6e1cb6469 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h @@ -80,21 +80,6 @@ namespace CGAL { return idx_ != inf; } - /// are two indices equal? - bool operator==(const T& _rhs) const { - return idx_ == _rhs.idx_; - } - - /// are two indices different? - bool operator!=(const T& _rhs) const { - return idx_ != _rhs.idx_; - } - - /// Comparison by index. - bool operator<(const T& _rhs) const { - return idx_ < _rhs.idx_; - } - // Compatibility with OpenMesh handle size_type idx() const { return idx_; @@ -120,7 +105,7 @@ namespace CGAL { SM_Index operator+=(std::ptrdiff_t n) { idx_ = size_type(std::ptrdiff_t(idx_) + n); return *this; } - private: + protected: size_type idx_; }; @@ -131,8 +116,8 @@ namespace CGAL { return ret; } - // Implementation for Surface_mesh::Vertex_index - + + // Implementation for Surface_mesh::Vertex_index class SM_Vertex_index : public SM_Index { @@ -142,6 +127,25 @@ namespace CGAL { explicit SM_Vertex_index(size_type _idx) : SM_Index(_idx) {} + template bool operator==(const T&) const = delete; + template bool operator!=(const T&) const = delete; + template bool operator<(const T&) const = delete; + + /// are two indices equal? + bool operator==(const SM_Vertex_index& _rhs) const { + return this->idx_ == _rhs.idx_; + } + + /// are two indices different? + bool operator!=(const SM_Vertex_index& _rhs) const { + return this->idx_ != _rhs.idx_; + } + + /// Comparison by index. + bool operator<(const SM_Vertex_index& _rhs) const { + return this->idx_ < _rhs.idx_; + } + friend std::ostream& operator<<(std::ostream& os, SM_Vertex_index const& v) { @@ -167,6 +171,25 @@ namespace CGAL { SM_Halfedge_index() : SM_Index((std::numeric_limits::max)()) {} explicit SM_Halfedge_index(size_type _idx) : SM_Index(_idx) {} + + template bool operator==(const T&) const = delete; + template bool operator!=(const T&) const = delete; + template bool operator<(const T&) const = delete; + + /// are two indices equal? + bool operator==(const SM_Halfedge_index& _rhs) const { + return this->idx_ == _rhs.idx_; + } + + /// are two indices different? + bool operator!=(const SM_Halfedge_index& _rhs) const { + return this->idx_ != _rhs.idx_; + } + + /// Comparison by index. + bool operator<(const SM_Halfedge_index& _rhs) const { + return this->idx_ < _rhs.idx_; + } friend std::ostream& operator<<(std::ostream& os, SM_Halfedge_index const& h) { @@ -183,7 +206,25 @@ namespace CGAL { SM_Face_index() : SM_Index((std::numeric_limits::max)()) {} explicit SM_Face_index(size_type _idx) : SM_Index(_idx) {} + + template bool operator==(const T&) const = delete; + template bool operator!=(const T&) const = delete; + template bool operator<(const T&) const = delete; + /// are two indices equal? + bool operator==(const SM_Face_index& _rhs) const { + return this->idx_ == _rhs.idx_; + } + + /// are two indices different? + bool operator!=(const SM_Face_index& _rhs) const { + return this->idx_ != _rhs.idx_; + } + + /// Comparison by index. + bool operator<(const SM_Face_index& _rhs) const { + return this->idx_ < _rhs.idx_; + } friend std::ostream& operator<<(std::ostream& os, SM_Face_index const& f) { @@ -218,6 +259,11 @@ namespace CGAL { // returns whether the index is valid, i.e., the index is not equal to std::numeric_limits::max(). bool is_valid() const { return halfedge_.is_valid(); } + + template bool operator==(const T&) const = delete; + template bool operator!=(const T&) const = delete; + template bool operator<(const T&) const = delete; + // Are two indices equal? bool operator==(const SM_Edge_index& other) const { return (size_type)(*this) == (size_type)other; }