Note 23.12.1.
Again, we are intentionally building a simplified version of
std::vector. Although our ArrayList is conceptually the same as a vector, it doesnβt provide exactly the same functionality. std::vector uses more complex code to handle element access.
std::vector does not have separate set and get functions. Instead, it provides an T& ArrayList<T>::at(int location) function. Because this function returns a reference, it allow consumers to write myList.at(2) = 100;. But it also provides a const version of exactly the same function: const T& ArrayList<T>::at(int location) const. The const version does not allow for assigning a new value, but can be used in contexts where we have said the vector itself is const.
It also provides an overridden
operator[] that does the same thing as .at() but skips the out_of_range check and just assume that the index is valid.
