title: "no matching function for call error" when calling constructor from helper function in g++
body: <p>I have a constructor </p>
  
  <pre><code>A::A(const Name&amp; n,const IRole&amp; r)
  : ...
  { }
  </code></pre>
  
  <p>And helper function that uses the contructor</p>
  
  <pre><code>AP&lt;A&gt; A::Create(const Name&amp; n, const IRole&amp; r)
  {
      return new A(n,r);
  }
  </code></pre>
  
  <p>And g++ gives me error messages when I compile this code.</p>
  
  <pre><code>error: no matching function for call to ‘AIR::AP&lt;AIR::A&gt;::AP(AIR::AP&lt;AIR::A&gt;)’
   note: candidates are:   AIR::AP&lt;T&gt;::AP(AIR::AP&lt;U&gt;&amp;) [with U = AIR::A, T = AIR::A]
   note:                   AIR::AP&lt;T&gt;::AP(AIR::AP&lt;T&gt;&amp;) [with T = AIR::A]
   note:                   AIR::AP&lt;T&gt;::AP(T*) [with T = AIR::A]
  error:   initializing temporary from result of ‘AIR::AP&lt;T&gt;::AP(T*) [with T = AIR::A]’
  </code></pre>
  
  <p>What's wrong with this code?</p>
  
  <h2>ADDED</h2>
  
  <pre><code>AP&lt;A&gt; A::Create(const Name&amp; n, const IRole&amp; r)
  {
      AP&lt;A&gt; port(new A(n,r));
      return port; 
  }
  </code></pre>
  
  <p>Seems to solve this issue.</p>