title: Can I have variadic template function returning different types?
body: <p>I'm doing some deserialization from byte array and made a ExtractData variadic template so it works like</p>
  
  <pre><code>QByteArray data; // (this works just like std::vector&lt;char&gt;)
  std::vector&lt;std::any&gt; values = ExtractData&lt;float, char&gt;(data); // read a float, char sequentially from data
  float readFloat = std::any_cast&lt;float&gt;(values[0]);
  float readChar = std::any_cast&lt;char&gt;(values[1]);
  </code></pre>
  
  <p>but still, a lot of boilerplate to decode stuff.<br>
  Ideally I'd want something like</p>
  
  <pre><code>float readFloat;
  char readChar;
  std::tie(readFloat, readChar) = ExtractData&lt;float, char&gt;(data);
  </code></pre>
  
  <p>ExtractData structure is basically</p>
  
  <pre><code>using anyVec = std::vector&lt;std::any&gt;;
  
  // one type resolution
  template&lt;typename T&gt;
  anyVec ExtractData(const QByteArray&amp; data, anyVec out = {}){
      // extract T value, assign to std::any, push_back into out
      return outVec;
  }
  
  // multiple types resolution
  template&lt;typename T, typename... Rest&gt;
  typename std::enable_if&lt;(sizeof...(Rest) &gt; 0), anyVec&gt;::type
  ExtractData(const QByteArray&amp; data, anyVec out = {}){
      // extract T value, assign to std::any, push_back into out
      return ExtractData&lt;Rest...&gt;(data, out);
  }
  </code></pre>
  
  <p>I just don't see how I could make <code>ExtractData&lt;type1, type2, ...&gt;(data)</code> return a <code>std::tuple&lt;type1, type2, ...&gt;</code> since all that original type info is lost when template type list "unwinds". Is it even possible? Sorry if I'm missing something obvious, I'm still quite new to c++11 and newer.</p>
  
  <p>I see that I could make a template for fixed amount of types, but that's not my use case sadly.</p>
  
  <hr>
  
  <p>I'm using Qt 5.11, c++14 (omitted <code>experimental</code> in namespaces here), but happy to hear c++17 advice too. Exact snippet of code I'm using: <a href="https://gist.github.com/tjakubo2/dc3e6897bf42f3bed78933031e53786b" rel="nofollow noreferrer">https://gist.github.com/tjakubo2/dc3e6897bf42f3bed78933031e53786b</a></p>