title: C++ Take a union of the parameters in a parameter pack of variadic templates?
body: <p>I've been writing a bit of code in C++ that involves a lot of metaprogramming; the code models a task that is defined at runtime by some series of nodes that take a number of inputs and, when run, produce some number of outputs. Inputs and outputs are linked in a directed graph. There's a bounded number of node types, which I'm storing in a variant, and each node class defines a static constexpr variable that, more or less, lists what types are input and output from that node. I'd like to be able to take a list of the classes of nodes and convert it into a list of the classes of data that are acted upon by the nodes.</p>
  
  <p>To be more explicit, if I have a template that purely tracks some list of classes at compile-time like this:</p>
  
  <pre><code>template&lt;class... Args&gt;
  struct ClassList{};
  </code></pre>
  
  <p>I want some sort of template that transforms list of lists like this:</p>
  
  <pre><code>ClassList&lt;ClassList&lt;int,int,double&gt;, ClassList&lt;double,char&gt;, ClassList&lt;char, char&gt; &gt;
  </code></pre>
  
  <p>into the union of the inner lists:</p>
  
  <pre><code>ClassList&lt;int,double,char&gt;
  </code></pre>
  
  <p>with no special requirements for order - except that each type appearing in the original lists appears exactly once in the final list - and if possible, I'd like to do this in a way that won't cause my compiler to explode. I know that I could, in theory, write a whole bunch of recursive templates that would join the lists into one and then remove duplicates, but that solution sounds a bit unsavory. Is there a better way?</p>