Merge pull request #4245 from afabri/SM-disable_incompatible_comparisons-GF

Surface_mesh: Disable comparison of mixed index types
This commit is contained in:
Laurent Rineau 2019-12-05 11:05:32 +01:00
commit b1c36bade5
1 changed files with 64 additions and 18 deletions

View File

@ -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<SM_Vertex_index>
{
@ -142,6 +127,25 @@ namespace CGAL {
explicit SM_Vertex_index(size_type _idx) : SM_Index<SM_Vertex_index>(_idx) {}
template<class T> bool operator==(const T&) const = delete;
template<class T> bool operator!=(const T&) const = delete;
template<class T> 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<SM_Halfedge_index>((std::numeric_limits<size_type>::max)()) {}
explicit SM_Halfedge_index(size_type _idx) : SM_Index<SM_Halfedge_index>(_idx) {}
template<class T> bool operator==(const T&) const = delete;
template<class T> bool operator!=(const T&) const = delete;
template<class T> 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<SM_Face_index>((std::numeric_limits<size_type>::max)()) {}
explicit SM_Face_index(size_type _idx) : SM_Index<SM_Face_index>(_idx) {}
template<class T> bool operator==(const T&) const = delete;
template<class T> bool operator!=(const T&) const = delete;
template<class T> 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<size_type>::max().
bool is_valid() const { return halfedge_.is_valid(); }
template<class T> bool operator==(const T&) const = delete;
template<class T> bool operator!=(const T&) const = delete;
template<class T> 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; }