C++ templates and implicit type conversion
<p>I have the following code:</p>

<pre><code>#include &lt;iostream&gt;
#include "boost/shared_ptr.hpp"

using boost::shared_ptr;

class Base {
 public:
  virtual ~Base() {}
  virtual void print() = 0;
};

template &lt;typename T&gt;
class Child : public Base {
 public:
  virtual void print() {
    std::cout &lt;&lt; "in Child" &lt;&lt; std::endl;
  }
};

class GrandChild : public Child&lt;int&gt; {
 public:
  virtual void print() {
    std::cout &lt;&lt; "in GrandChild" &lt;&lt; std::endl;
  }
};

template &lt;typename T&gt;
void call_print(shared_ptr&lt;Child&lt;T&gt; &gt; a) {
  a-&gt;print();
}

void call_base_print(shared_ptr&lt;Base&gt; a) {
  a-&gt;print();
}

int main() {
  shared_ptr&lt;GrandChild&gt; gchild(new GrandChild);
  call_print(shared_ptr&lt;Child&lt;int&gt; &gt;(gchild));
  // call_print(gchild);  // Cannot compile!
  call_base_print(gchild);  // This works.
  return 0;
}
</code></pre>

<p>I found it strange that <code>call_base_print(gchild)</code> works but <code>call_print(gchild)</code> causes a compiler error. I know that C++ does not allow two implicit conversions, but I don't think there're two conversions here... Could anyone enlighten me?</p>
