title: auto return type for a C++ member function of a template class
body: <p>For the sake of readability I will simplify my problem into a nice toy example:</p>
  <p>Let's say I have a template class <code>Box</code> which can hold a finite collection of objects of a given type (initialised as <code>Box&lt;double, 10&gt;</code>). The class has a member function called <code>expand(n)</code> which  should modify the box such that the capacity is higher. Since the <code>10</code> is a specification of class instance I believe it is reasonable for the method to return a new object instead (ex. <code>Box&lt;double, 20&gt;</code>, for the function argument <code>n</code> given <code>20</code>).</p>
  <p>I am having problems with a proper signature for the method. What I have is:</p>
  <pre class="lang-cpp prettyprint-override"><code>template &lt;typename T, const unsigned int size&gt;
  Box Box&lt;T, size&gt;::expand(const unsigned int newsize) const {
  </code></pre>
  <p>Naturally, the problem is with the return type... I cannot just add <code>&lt;T, newsize&gt;</code> since the latter is not yet in the scope.</p>
  <p>I have been trying to use a trailing return syntax:</p>
  <pre class="lang-cpp prettyprint-override"><code>template &lt;typename T, const unsigned int size&gt;
  auto Box&lt;T, size&gt;::expand(const unsigned int newsize) -&gt; Box&lt;T, newsize&gt; const {
  </code></pre>
  <p>But something is wrong here and I get errors..
  How should I modify it?</p>