title: Dynamic Pointer Cast
body: <p>I'd like to convert a base class pointer to a derived class pointer as a function argument without using dynamic_pointer_cast</p>
  
  <pre><code>class Base 
  {
      public:     
      typedef std::shared_ptr &lt; Base &gt; Ptr;
      virtual ~Base ( );
      ...
  };
  
  class Derive : public Base
  {
      public:
      typedef std::shared_ptr &lt; Derive &gt; Ptr;
      ...
  };
  
  void foo( Derive::Ptr ptr )
  {
      ... 
  }
  
  Base::Ptr ptr1 ( new Derive );
  foo( ptr1 );
  </code></pre>
  
  <p>The above code will give an error while calling foo. This can be avoided by typecasting ptr1 into a Dervie pointer using std::dynamic_pointer_cast. </p>
  
  <pre><code>Base::Ptr ptr1 ( new Derive );
  foo ( std::dynamic_pointer_cast &lt; Derive &gt; ( ptr1 ) );
  </code></pre>
  
  <p>I want to create a map of callback functions that will automatically typecast a base class pointer and call the corresponding function based on the type of derived class.</p>