Obviously, in this sentence
for (auto i: arr) std::cout << "i" << "\n"; ^^^^
you made a typo. Most likely you had in mind
for (auto i: arr) std::cout << i << "\n"; ^^^^
As for your question, in addition to obtaining the values of the elements of the array to obtain the values of the indexes of the elements of the array, you will in any case have to enter an additional variable.
Therefore, in such cases it is better to use the usual for clause.
for ( size_t i = 0; i < sizeof( arr ) / sizeof( *arr ); i++ ) { std::cout << arr[i] << "\n"; }
Range-based loops are entered in order to break free of a variable, which is usually not needed when outputting array values. Using a variable to store indexes is often the cause of numerous errors either when the indexing is not started from 0, but from, for example, 1, or when the upper value of the index range is incorrect.
for (;;)to help. - Vladimir Gamalyan