I have know idea how this program works and it was a question in a past exam. Can you please provide a link to a guide or a walk through of how this program returns: 50 30 20 10 .
std::set<> holds an ordered set of unique objects.
The ordering is based on the comparison predicate - in this example, std::greater<int>
The ordering imposed by std::greater<int> is that if a compares greater than b - a>b is true - a would appear before b in the ordered sequence. Therefore, the integers in the set are held in descending order 50 30 20 10.