Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix off-by-one bug in FlatSet::difference_with
Summary: The current implementation of `FlatSet::difference_with()` performs an increment on the iterator returned by `m_set.erase()`. Since `m_set.erase()` will move the iterator to the next element after the element being erased, incrementing the iterator again creates an off-by-one bug, which manifests if consecutive elements in `this` is also in `other`. Consequently we have the following incorrect behavior: ``` sparta::FlatSet<int> s1{1, 2, 3, 4}; sparta::FlatSet<int> s2{1, 2, 3, 4}; std::cerr << s1.get_difference_with(s2) << std::endl; // expected {}, got {2, 4} ``` Reviewed By: anwesht, arnaudvenet Differential Revision: D60269360 fbshipit-source-id: 7bb9a19eeab42e98bf2fd45b583ce5bcd21a8dd7
- Loading branch information