The "container requirements" state that X(il)
is the "Same as X(il.begin(),
il.end())
" (for an initializer list il
), so the result is standardized and as expected, namelt, the elements are inserted in order.
Unordered_map constructed from initializer list with repeated keys
-
21-09-2022 - |
質問
What does the standard guarantee will happen if an unordered_map
(or more generally a unique associative container) is constructed with an initializer_list
with repeated keys? Is it undefined or does it have unique compliant behavior? gcc 4.7 accepts code like this
std::unordered_map<int, int> x = {{1,1}, {1,2}};
but that doesn't tell me what is guaranteed by the standard.
解決
所属していません StackOverflow