Consider
#include <iostream>
// Print n x m - Matrix A
template<typename T, size_t N, size_t M>
void printMatrix(T (&A)[N][M]) {
    for(int i=0; i<N; ++i) { // Rows
        for(int j=0; j<M; ++j) { // Columns
            std::cout << A[i][j] << " ";
        }
        std::cout << "\n";
    }
}
int main() {
    int A[2][2] = { {1,2},{3,4} };
    printMatrix(A);
    
    return 0;
}
The code works and I can see that T is deduced from the argument but I'm wondering how exactly the compiler deduces the values of N and M.
 
     
    