title: General rules of passing/returning reference of array (not pointer) to/from a function?
body: <p>We can pass reference of an array to a function like:</p>
  
  <pre><code>void f(int (&amp;a)[5]);
  
  int x[5];
  f(x);     //okay
  int y[6];
  f(y);     //error - type of y is not `int (&amp;)[5]`.
  </code></pre>
  
  <p>Or even better, we can write a function template:</p>
  
  <pre><code>template&lt;size_t N&gt;
  void f(int (&amp;a)[N]); //N is size of the array!
  
  int x[5];
  f(x);     //okay - N becomes 5
  int y[6];
  f(y);     //okay - N becomes 6
  </code></pre>
  
  <hr>
  
  <p>Now my question is, how to return reference of an array from a function?</p>
  
  <p>I want to return array of folllowing types from a function:</p>
  
  <pre><code>int a[N];
  int a[M][N];
  int (*a)[N];
  int (*a)[M][N];
  </code></pre>
  
  <p>where <code>M</code> and <code>N</code> is known at compile time!</p>
  
  <p>What are general rules for passing and returning compile-time reference of an array to and from a function? How can we pass reference of an array of type <code>int (*a)[M][N]</code> to a function?</p>
  
  <p>EDIT:</p>
  
  <p><strong>Adam</strong> commented : <code>int (*a)[N]</code> is not an array, it's a pointer to an array.</p>
  
  <p>Yes. But one dimension is known at compile time! How can we pass this information which is known at compile time, to a function?</p>