If I array size is static you should be able to replace it with std::array with no code modifications; it'll throw exception right away if you go out of bounds.
If it's dynamic then you can use std::vector, but that requires a bit code modification.