Iterator seems to be breaking

Hi!

I'm trying to find 2 squares in a collection of squares that overlap.
Here's the segment of my code that's buggy: https://hatebin.com/apaolkatzj
`relevant` is a `set`, and `IDSquare` is just a custom class. `overlapping` is a `vector` of `pair`s. However, sometimes the `upper` iterator seems to be returning an element that isn't in the set at all. I'm particularly baffled by this because I did perform a check for if `prescence` was at the end already.

Am I missing something? Any help would be appreciated!
Last edited on
I'm particularly baffled by this because I did perform a check for if `prescence` was at the end already.

"At the end" means one-past-the-end.
So it could be at the very last element.
But then you increment upper, so now it could be one-past-the-end.
Topic archived. No new replies allowed.