fix for STL debug mode

It is invalid to try to detect if an iterator is singular or value-initialized.
The only operations allowed with value-initialized iterators are:
  - copy the iterator, or
  - destroy or assign the iterator.

Comparisons like `vertex_it == Vertex_it{}` are not allowed.
This commit is contained in:
Laurent Rineau 2025-01-30 17:51:20 +01:00
parent 571c2ccadc
commit d837dbde21
1 changed files with 3 additions and 18 deletions

View File

@ -365,26 +365,11 @@ public:
// - Otherwise all members must be valid pointers or dereferencable iterators.
bool is_singular() const {
CGAL_assertion((hierarchy == nullptr) == (constraint_it == Constraint_iterator{}));
CGAL_assertion((hierarchy != nullptr) || (vertex_it == Vertex_it{}));
return hierarchy == nullptr;
}
bool is_valid() const {
if(hierarchy == nullptr) {
CGAL_assertion(is_singular());
return false;
}
if(constraint_it == Constraint_iterator{}) {
return false;
}
if(constraint_it == hierarchy->constraints_end()) {
return vertex_it == Vertex_it{};
}
if(vertex_it == Vertex_it{}) {
return false;
}
return true;
return (hierarchy != nullptr);
}
bool is_end() const {
@ -406,8 +391,8 @@ public:
bool equal(const Subconstraint_iterator& other) const {
if(hierarchy != other.hierarchy) return false;
if(is_singular()) return true;
return (constraint_it == other.constraint_it &&
vertex_it == other.vertex_it);
return (constraint_it == other.constraint_it) && (this->is_end() == other.is_end());
}
Vertex_it begin_or_null(Constraint_iterator constraint_it) const {