title: What will destructor of a std::variant do if it contains void* data
body: <p>I have just started using <code>std::variant</code> in my projects. I have a doubt. What will the destructor of <code>std::variant</code> do in the code shown below. Variant holds a <code>void*</code> data. Once variant goes out of scope, I think it will only free the memory of <code>void*</code> but not the actual object the pointer was pointing to. So there will be memory leak in this case. I would like to know if my understanding is correct or not.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;memory&gt;
  #include &lt;variant&gt;
  using namespace std;
  
  class A {
      public:
      ~A(){
          cout&lt;&lt;"Destructor called"&lt;&lt;endl;
      }
  };
  
  
  int main() {
      std::variant&lt;void*&gt; data;
      A* b = new A();
      data = (void*)b;
      return 0;
  }
  </code></pre>