title: C++ 11 passing shared_pointer like with std::any
body: <p>at the moment I'm facing following problem. I need a member function in a derived class that can handle different shared_ptr types and do custom stuff with it. The base class should make sure that such a member function is implemented but the specific shared_ptr types are only known when a other developer create a new derived class. Therefore, templates are not a solution due to the fact that c++ not support virtual template functions.</p>
  
  <p>The shared_ptrs hold protobuf message specific publisher or subscriber. Here a snipped of code:</p>
  
  <pre><code>std::shared_ptr&lt;Publisher&lt;ProtobufMessageType1&gt;&gt; type1 = std::make_shared&lt;ProtobufMessageType1&gt;();
  std::shared_ptr&lt;Publisher&lt;ProtobufMessageType2&gt;&gt; type2 = std::make_shared&lt;ProtobufMessageType2&gt;();
  
  class derived : base
  {
  
    void takeThePointerAndDoSpecificStuff( std::shared_ptr&lt;PubOrSub&lt;SpecificProtobufMessage&gt;&gt;) override
    {
       // check type and bind specific callback
    }
  }
  </code></pre>
  
  <p>One solution could be casting shared_ptr to base class but it is not possible because the protobuf message base class is pure virtual. Another solution is to cast the raw pointer and only transfer this one but I need the share_ptr reference count also in the method ( due to binding).</p>
  
  <p>So I look further for a solution and std::any could be one but the problem here is that c++11 not have a std::any (sure could use boost but I try to avoid that).</p>
  
  <p>So now I'm out of ideas how to solve the problem but perhaps you have one and can help me. </p>
  
  <p>Thank you for any answer in advance.</p>