title: Object created in Python via Pybind11 not recognized as a derived class by C++ functions
body: <p>The minimum code to reproduce the issue is as follows:</p>
  <p><code>aaa.hpp</code></p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;iostream&gt;
  #include &lt;stdexcept&gt;
  #include &lt;cmath&gt;
  #include &lt;cassert&gt;
  #include &lt;utility&gt;
  
  
  template &lt;typename D&gt;
  class BaseClass{
      /* The base class. */
  protected:
      bool skip_nan = true;
  };
  
  template &lt;typename D&gt;
  class DerivedClass : public BaseClass&lt;D&gt;{
  public:
      explicit DerivedClass(bool skip_nan_){ this-&gt;skip_nan = skip_nan_; }
  };
  
  </code></pre>
  <p><code>aaa_py.cpp</code></p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;pybind11/pybind11.h&gt;
  #include &lt;pybind11/numpy.h&gt;
  #include &lt;pybind11/stl.h&gt;
  #include &quot;aaa.hpp&quot;
  namespace py = pybind11;
  
  
  template &lt;typename D&gt;
  void fff(BaseClass&lt;D&gt;&amp; rs){
  
  }
  
  
  PYBIND11_MODULE(aaa_py, m) {
      m.def(&quot;fff_float&quot;, &amp;fff&lt;float&gt;);
      py::class_&lt;DerivedClass&lt;float&gt;&gt;(m, &quot;DerivedClass_float&quot;).def(py::init&lt;bool&gt;(), py::arg(&quot;skip_nan&quot;)=true);
  }
  </code></pre>
  <p><code>test.py</code></p>
  <pre class="lang-py prettyprint-override"><code>import aaa_py as rsp
  ds = rsp.DerivedClass_float()
  rsp.fff_float(ds)
  </code></pre>
  <p>Error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;usage_example_python.py&quot;, line 8, in &lt;module&gt;
      rsp.fff_float(ds)
  TypeError: fff_float(): incompatible function arguments. The following argument types are supported:
      1. (arg0: BaseClass&lt;float&gt;) -&gt; None
  
  Invoked with: &lt;aaa_py.DerivedClass_float object at 0x000002C9EAF57308&gt;
  </code></pre>
  <p>Basically the error is saying that function <code>fff_float</code> expects somebody from <code>BaseClass&lt;float&gt;</code>, but receives <code>DerivedClass&lt;float&gt;</code>. If I change the function to accept <code>DerivedClass&lt;D&gt;&amp;</code>, then there would be no errors. Or, if I create an instantiation of <code>DerivedClass&lt;float&gt;</code> directly in c++ and pass it to the <code>float_fff</code>, there would also be no issues. So it seems that the issue is that for an object created in Python, somehow the information about its base class is lost. How can I deal with this?</p>