title: Casting shared_ptr<T> to shared_ptr<void>
body: <p>I have a structure:</p>
  
  <pre><code>struct Params {
     std::shared_ptr&lt;void&gt; user_data;
     /* ... */
  };
  </code></pre>
  
  <p>I want to use it like this:</p>
  
  <pre><code>int main() {
    std::shared_ptr&lt;SpecializedParams&gt; sp(new SpecializedParams(100));
    Params params;
    /* ... */
    params.user_data = std::static_pointer_cast&lt;void&gt;(sp); 
    /* ... */
    std::shared_ptr&lt;SpecializedParams&gt; sp2 = 
      std::static_pointer_cast&lt;SpecializedParams&gt;(
        params.user_data
      );
    /* ... */
    return 0;
  }
  </code></pre>
  
  <p>Is this valid and safe?</p>