In C++, for a vector v, v.at(x) behaves like v[x], except that it throws an out of bounds error if a non-existent element is accessed.
I would like to ideally always use v.at(x), however, it is not as convenient to write as v[x]. Is there a way I can make v[x] behave like v.at(x), perhaps using something like #define?
If not, is there a better solution for out-of-bounds errors to always be thrown?
Aucun commentaire:
Enregistrer un commentaire