title: What are the advantages of using std::variant as opposed to traditional polymorphic processing?
body: <p>Suppose I have a <code>Shape</code> base class and <code>Circle</code>, <code>Line</code>, and <code>Point</code> derived classes. I have two functions.</p>
  
  <pre><code>std::variant&lt;Circle, Line, Point&gt; process(const Shape &amp;s);
  Shape process(const Shape&amp; s);
  </code></pre>
  
  <p>I can pass in any of my derived classes and return a Shape object in the second function, a variant is just a union that can hold any of my derived class variables at any given time.</p>
  
  <p>Now with <code>std::variant</code> I can also employ a <code>visitor</code> where I can process some function depending on what type my variant is currently holding (I could just create a function object and pass it <code>std::transform</code> and apply it to each of my objects). However, I can just make that function <code>virtual</code> in my base class and have each derived class implement it.</p>
  
  <p>So, is <code>variant</code> just a convenience?</p>