c++ - Are the elements in a std::map guaranteed to be ordered? -
Is this just an implementation side effect (red-black tree) or is the order guarantee by C ++ standard?
The ordered execution is not an implementation description; It is guaranteed by the C ++ standard; It is the basic asset of all the Associated Containers (C + 03 03 § 23.1.2 / 9):
The basic properties of the organizers of associative containers are: That they determine the sequence of non-keys through the container where the non-descending definition is defined, which was used to make them. From any two dereferenceable iterators
i
andj
to that distance thati
toj
is positive,value_comp (* j, * i) == false
value_comp
comparator with which map was created (By default, this is std :: less
Comments
Post a Comment