title: How to let a method access private members of other template class instances?
body: <p>This extremely minimal example will fail to compile because <code>A&lt;int&gt;</code> cannot access the private member <code>i</code> in <code>A&lt;double&gt;</code></p>
  
  <pre><code>template &lt;class T&gt;
  class A {
      int i;
    public:
      template &lt;class U&gt;
      void copy_i_from( const A&lt;U&gt; &amp; a ){
          i = a.i;
      }
  };
  
  int main(void) {
      A&lt;int&gt; ai;
      A&lt;double&gt; ad;
      ai.copy_i_from(ad);
      return 0;
  }
  </code></pre>
  
  <p>I know that I can make all the template instances friends of each other (see: <a href="https://stackoverflow.com/questions/26422160/how-to-access-private-members-of-other-template-class-instances">How to access private members of other template class instances?</a>), but since I have only one method that requires the access (like in the example) I would prefer to limit the friendship to that method. Is this possible?</p>