#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.