c++ - Handling Out-of-Range Indices -


For a container class, what behavior should be when the class of the user tries to set a value outside the class size ?

There is a "replacement" method (such as operator [] ) rather than "one" method in question (such as operator + = ).

I could throw an out_of_range exception, or I could adjust to change the size of the container.

One exception to the limit is more appropriate here because the word "replacement" usually means the word That the caller assumes that the data in the specified index is not, which is not.

Comments