title: Convert void * to shared_ptr of a type
body: <p>In below code I am trying to convert a void* to a shared_ptr of a type:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;memory&gt;
  class A
  {
  public:
  A(){l=0;}
  int l;
  void Show() { std::cout &lt;&lt; l &lt;&lt; "\n";}
  };
  
  void PrintA(void *aptr)
  {
  std::shared_ptr&lt;A&gt; a1;
  a1.reset(aptr);
  a1-&gt;Show();
  }
  
  int main()
  {
  std::shared_ptr&lt;A&gt; a(new A());
  PrintA(a.get());
  }
  </code></pre>
  
  <p>But I get below compilation error:</p>
  
  <pre><code>$ c++ -std=c++14 try20.cpp
  In file included from C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/shared_ptr.h:52:0,
                   from C:/tools/mingw64/x86_64-w64-mingw32/include/c++/memory:82,
                   from try20.cpp:2:
  C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/shared_ptr_base.h: In instantiation of 'std::__shared_ptr&lt;_Tp, _Lp&gt;::__shared_ptr(_Tp1*) [with _Tp1 = void; _Tp = A; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]':
  C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/shared_ptr_base.h:1023:4:   required from 'void std::__shared_ptr&lt;_Tp, _Lp&gt;::reset(_Tp1*) [with _Tp1 = void; _Tp = A; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]'
  try20.cpp:14:14:   required from here
  C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/shared_ptr_base.h:871:39: error: invalid conversion from 'void*' to 'A*' [-fpermissive]
           : _M_ptr(__p), _M_refcount(__p)
                                         ^
  C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/shared_ptr_base.h:874:4: error: static assertion failed: incomplete type
      static_assert( !is_void&lt;_Tp1&gt;::value, "incomplete type" );
  </code></pre>
  
  <p>How can I convert a void pointer to a shared pointer of a type?</p>