Issue 175086
Summary [libc++] flat_set uses 2x as many comparisons as it should
Labels libc++
Assignees
Reporter halbi2
    ```
#include <flat_set>
#include <iostream>

int Count = 0;
struct Comp { bool operator()(int x, int y) const { ++Count; return x < y; } };

int main() {
  std::flat_set<int, Comp> x = {0,0,0,0,0,0,0,0,0,0};
  std::cout << Count;
}
```
This program uses 27 comparisons. It can be done in 18. The problem is that `flat_set::__key_equiv` always calls the comparator twice instead of once. I will post a patch for this.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to