title: C++ decltype deducing current function returned type
body: <p>I would like to automatically deduce the returned type of the function I'm writing.</p>
  <p>Example:</p>
  <pre><code>std::vector&lt;int&gt; test(){
      decltype(this_function) ret;
      ret.push_back(5);
      ret.push_back(9);
      return ret;
  }
  </code></pre>
  <p>So far the best I've achieved is</p>
  <pre><code>std::vector&lt;int&gt; test(){
      decltype(test()) ret;
      ret.push_back(5);
      ret.push_back(9);
      return ret;
  }
  </code></pre>
  <p>Which works but:</p>
  <ol>
  <li><p>If I change function name I must change</p>
  <p><code>decltype(test())</code></p>
  <p>into</p>
  <p><code>decltype(name())</code></p>
  </li>
  <li><p>If I change function parameters I must change as well</p>
  <p><code>decltype(test())</code></p>
  <p>into</p>
  <p><code>decltype(test(param1, param2))</code></p>
  </li>
  </ol>
  <p>Is there a more elegant way of doing the same?</p>