std::set<int, std::less_equal<int>> myset = {1,1,7,8,2,2};
myset.insert(99);
myset.insert(99);
for(const int & val : myset)
std::cout << val << " ";
output:
1 1 2 2 7 8 99 99
Hello, while i was studying on containers. i realized that when i use less_equal function, standart set container behaves just as a multiset container. Is this normal? if it is, what is the difference between multiset and set?
Is this normal?
No, it is not normal. Your cannot specify std::less_equal as a comparator for std::set because it does not satisfy the strict weak ordering rules.
See the requirements here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With