title: Why isn't argument deduction allowed in function return type?
body: <p>The most obvious answer could be - <em>because the standard says so</em>.<br>
  That's fine, but I'm wrapping my head around it to understand the reasons behind this choice.</p>
  
  <p>Consider the following example:</p>
  
  <pre><code>template&lt;typename T&gt;
  struct S { S(T) {} };
  
  S f() { return 0; }
  
  int main() {
      auto s = f();
      (void)s;
  }
  </code></pre>
  
  <p>It fails to compile with errors like:</p>
  
  <blockquote>
    <p>error: use of class template 'S' requires template arguments; argument deduction not allowed in function return type</p>
  </blockquote>
  
  <p>Quite easy to fix, it isn't a problem, something like this works just fine:</p>
  
  <pre><code>auto f() { return S{0}; }
  </code></pre>
  
  <p>However, I'd like to understand what were the drawbacks of allowing class template arguments deduction also in function return types.<br>
  At a first glance, it looks just like a silly limitation, but I'm pretty sure I'm missing something important here.</p>