The C++ standard defines a std::map constructor using a std::initializer_list:
map( std::initializer_list<value_type> init, const Allocator& );
However, where is defined what happens if the initializer list contains duplicate keys? Is the first key choosen, or the last? For example:
std::map<std::string, int> my_map {
{"a", 1},
{"a", 2}
};
In practice, it seems it behaves like insert(), so that the map will now contain {a: 1}.
However, I was unable to find anything in the C++ standard regarding this.
N4296 (~C++14)
Then from above in the table, for the iterator ctor:
and
Note that "and inserts elements" here is not marked up to indicate the
insertfunction, but I suppose we may interpret it that way. Also note thatiandjare input iterators, so must be traversed in order..
(It is slightly harder to find this information, because the equivalent tables all have
above them, so can be found by searching for
initializer_list, but for this table the word is split over two lines, with a hyphen at the break.)