Is indexing a new map element and having something that reads it assigned to it undefined behaviour, or just unspecified?
问题 After answering this question, there was a long discussion over whether the code in question was undefined behaviour or not. Here's the code: std::map<string, size_t> word_count; word_count["a"] = word_count.count("a") == 0 ? 1 : 2; First of all, it was well-established that this was at least unspecified. The result differs based on which side of the assignment is evaluated first. In my answer, I followed through each of the four resulting cases, with factors of which side is evaluated first