Here http://www.cplusplus.com/reference/stl/set/ I read that std::set in C++ is “typically” implemented as a tree (red-black one?) and it is sorted.
I could not understand, does it mean that by specification iteration order of set is always ascending? Or is it only “usual implementation detail” and sometimes, some library/compiler may violate this convention?
Per the C++ standard, iteration over the elements in an
std::setproceeds in sorted order as determined bystd::lessor by the optional comparison predicate template argument.(Also per the C++ standard, insertion, lookup and deletion take at most O(lg n) time, so balanced search trees are currently the only viable implementation choice for
std::set, even though the use of red-black trees is not mandated by the standard.)