operator[] makes coding much simpler and clearer when accessing elements in random_acess_ranges like vector and deque. It is also useful for the bidirectional_ranges like map and unordered_map. We could like to use operator[] in the graph algorithms and doing so would support writing more generic code, but the concepts for those ranges don’t require operator[].

 

Is there a reason operator[] isn’t a requirement for random_access_range? For bidirectional_range?

 

We would create a concept that would require operator[]. What caveats are there in doing that?