title: C++: Declaring `auto` function return type in prototype still leads to use of `auto` before deduction error
body: <p>I wrote a function called <code>generate_random_matrix</code> with a return type of <code>auto</code> in the following code snippet. When I put the function before the <code>main</code> function, the code works fine. But when I put the function below the <code>main</code> function, and include a prototype at the top, the code gives me the usual error</p>
  
  <pre><code> error: use of ‘auto generate_random_matrix(double, double) [with int rows = 10; int cols = 10]’ before deduction of ‘auto’
       auto test_matrix = generate_random_matrix&lt;10,10&gt;(0, 2);
  </code></pre>
  
  <p>Here is the actual code snippet that is not working. Any suggestions as to why this is not working?</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;array&gt;
  #include &lt;random&gt;
  #include &lt;iostream&gt;
  
  std::random_device rd;
  std::mt19937 gen(rd());
  
  template &lt;int rows, int cols&gt;
  auto generate_random_matrix(double lower_, double upper_);
  
  int main()
  {
      auto test_matrix = generate_random_matrix&lt;10,10&gt;(0, 2);
      for (int i = 0; i &lt; 5; ++i)
      {
          for (int j = 0; j &lt; 10; ++j)
          {
              std::cout &lt;&lt; test_matrix[i][j] &lt;&lt; " ";
          }
          std::cout &lt;&lt; "\n";
      }
  }
  
  
  template &lt;int rows, int cols&gt;
  auto generate_random_matrix(double lower_, double upper_)
  {
  
      std::vector&lt;std::vector&lt;double&gt;&gt; result;
      std::vector&lt;double&gt; inner_result;
      for (int i = 0; i &lt; rows; i++) {
          inner_result.erase(inner_result.begin(), inner_result.end());
          for (int j = 0; j &lt; cols; j++) {
              inner_result.push_back(std::uniform_real_distribution&lt;double&gt;(lower_, upper_)(gen));
          }
          result.push_back(inner_result);
      }
  
      return result;
  }
  </code></pre>