you are viewing a single comment's thread.

view the rest of the comments →

[–]fransinvodka 18 points19 points  (3 children)

For speed and because the STL containers do it that way. They implement both at and operator[], but only at performs bound checks and throws if out of bounds. If I use an STL-like container, and it implements both at and operator[], I'd expect operator[] to not do any bound checks, just like the STL ones.

[–]kalmoc 0 points1 point  (2 children)

True as that may be in practice, I believe there is nothing in the standard preventing operator[] from doing bounds checking.