title: How is it possible that std::shared_ptr<Derived> casts to std::shared_ptr<Base> with no compiler errors?
body: <p>I'm trying to implement a custom smart pointer. So I have something like this:</p>
  <pre><code>// Base class for every object
  class Base {
  public:
      int n_holders {};
  };
  
  class Derived : public Base {};
  
  // Custom shared pointer
  template&lt;class T&gt;
  class Sptr {
  public:
      T* obj;
      Sptr(T* obj_) : obj{obj_} {}
  };
  
  void SomeFunc(Sptr&lt;Base&gt; obj) {}
  
  void SomeFunc2(std::shared_ptr&lt;Base&gt; obj) {}
  
  int main()
  {
      auto a = Sptr&lt;Base&gt;(new Base());
      SomeFunc(a); // OK
  
      auto b = Sptr&lt;Derived&gt;(new Derived());
      SomeFunc(b); // Error. No matching function call to SomeFunc
  
      auto c = std::shared_ptr&lt;Base&gt;(new Base());
      SomeFunc2(c); // OK
  
      auto d = std::shared_ptr&lt;Derived&gt;(new Derived());
      SomeFunc2(d); // OK !!!
  }
  </code></pre>
  <p>My question is why compiler can't automatically cast from <code>Sptr&lt;Derived&gt;</code> to <code>Sptr&lt;Base&gt;</code> if using <code>std::shared_ptr</code> there is no errors?. How to make it possible?</p>