operator[] for unordered_map and map

Why don't std::unordered_map and std::map have read-only versions of the subscript operator? At the very least, the read-only version could just call at(), right?
Then operator[] would have different semantics for const and non-const map objects. That isn't desireable. Why don't you just use at() for both const and non-const map objects if that is the behavior you're looking for?
Okay, so consistency is a major factor in not having a read-only version.

I am currently using at(). I guess I would prefer the subscript operator for maps because I am used to using std::vector and std::array.
Topic archived. No new replies allowed.