title: Expand variadic template template parameters for use in e.g. std::variant<T...>
body: <p>This will be a hard nut to crack. I don't even know if it's possible.</p>
  <p>My goal is to create a receive function that listens to multiple queues and pastes the object received via the particular queue (that responds first) to the stack in the return statement. This will be done via std::variant. The tricky bits are types: Every queue holds different types, so the variant inside multireceive() needs to be constructed from the template parameters used for the queues passed into it as varargs. Of course in the end the queue objects should only be passed as references.</p>
  <p>Here's my approach so far, but you can see I'm very unclear about how to write the pack expansions. I think I'm probably scratching the limits of C++ with this:</p>
  <pre><code>#include &lt;array&gt;
  #include &lt;variant&gt;
  
  template &lt;typename T&gt;
  struct queue
  {
      T queue_[100];
      
      T receive()
      {
          return queue_[0];
      }
  };
  
  // doesn't compile!
  template &lt;template &lt;typename... T&gt; class Q&gt;
  std::variant&lt;T...&gt; multireceive(Q&lt;T&gt;&amp;... Arg)
  {
      std::array&lt;std::variant&lt;Arg*...&gt;, sizeof...(T)&gt; queues = { (&amp;Arg )... };
  
      do {
          for (size_t i=0; i &lt; sizeof...(T); ++i) {
              if (queues[i]-&gt;receive()) {
                  return *queues[i];
              }
          }
      } while(1) // busy wait
  }
  
  int main() {}
  </code></pre>
  <p>Clearly this doesn't even remotely compile, its just me trying to show intent. The queue is of course also just a stub. Afaik you can't even grab the template template parameter by name (<code>T</code>) which is very unfortunate. Has someone smarter than me already figure out how to solve that problem?</p>
  <p><strong>Note</strong>:</p>
  <p>The way I did it until now is via dynamic dispatch over a non-templated base_struct. This solution however loses type information and my plan is to dispatch the variant via std::visit at the callsite of <code>multireceive</code>. This would then be a very neat solutions to dispatch directly from queue events.</p>