title: remove_pointer for unique_ptr's
body: <p>Suppose I'm writing a board game with a playable AI.  <code>class Board</code> takes two template parameters: P and N.  N is the number of players.  P is either <code>unique_ptr&lt;Player&gt;</code> or <code>Player</code>.  I use <code>unique_ptr&lt;Player&gt;</code> when actually playing the game, because <code>Player</code> has two child classes (<code>Human</code> and <code>AI</code>), but when the AI searches game states, it uses the same <code>Board</code> class but with T = Player (I chose this for a potential performance gain, e.g. data will be local, less indirections, and heap should be less fragmented).</p>
  
  <p><strong>Question:</strong> How would I define the operator[] which returns a reference to one of the players (e.g. if T = unique_ptr it returns *arr_[i], else returns arr_[i]).  Below is an attempt, but doesn't compile. Also, feel free to comment on design (e.g. in theory, can I really see a performance gain by introducing P?).</p>
  
  <pre><code>template&lt;typename P, size_t N&gt;
  class Board
  {
  public:
    P&amp; operator[] (size_t idx) { return helper(arr[idx]); }
  private:
    template&lt;typename I, typename O&gt;
    inline O&amp; helper(I&amp; input)
    {
      return input;
    }
    template&lt;&gt;
    inline P&amp; helper&lt;unique_ptr&lt;P&gt;,P&gt;(unique_ptr&lt;P&gt; input)
    {
      return *input;
    }
    std::array&lt;P,N&gt; arr_;
  };
  </code></pre>
  
  <p>Compiler errors:</p>
  
  <ol>
  <li>explicit specialization in non-namespace scope 'class Foo'</li>
  <li>template-id helper,T> in declaration of
      primary template</li>
  </ol>