4 ms·
The historic reason is that in C, [] on arrays is defined as returning an lvalue on which assignment then operates - that is, they have always been separate thi
by int_19h 4y ago
The historic reason is that in C, [] on arrays is defined as returning an lvalue on which assignment then operates - that is, they have always been separate things, and there was no operator []= or anything like that to define semantics of array assignment in a single operation.
C++ simply generalized this model to all collections, in line with the overall "better C" design. But then for maps it means that [] has to proactively create an entry if you want []= to work like it does everywhere else.
Similarly, C++ iterators are generalized C pointers, which is also not an ideal abstraction in practice (and why few other languages do it that way).