How does subscripting multiple times work for std::array even though all operator[]returns is a reference, without using any proxy-objects (as shown here)?
Example:
#include <iostream>
#include <array>
using namespace std;
int main()
{
array<array<int, 3>, 4> structure;
structure[2][2] = 2;
cout << structure[2][2] << endl;
return 0;
}
How/why does this work?
array<array<T, N>, M>you literally have an array of arrays, so subscripting the outer object returns a reference to an array, which you can then subscript. No proxy needed, because this case is much simpler!int*p, you can computep+6+2. Same thing.