title: C++ variadic template return type
body: <p>My function calls a Python function with a set of given input arguments (variadic) and returns a tuple containing the function's output (variadic because output varies on the function called). </p>
  
  <p>I'm compiling on a Windows 10 machine via MinGW-w64 compiler's port of g++ using C++11. I've declared this templated variadic function (and call it) as follows:</p>
  
  <pre><code>// Declaration (in PyInterface.h)
  template &lt;typename... Inputs, typename... Outputs&gt;
  const std::tuple&lt;Outputs...&gt;&amp; callFunction(const std::string &amp;modulePath, const std::string &amp;funcName, Inputs&amp;&amp;... args) { 
      // Calls a Python function &amp; packs output variables into a std::tuple... 
  }
  
  // Sample call (in main.cpp)
  const std::tuple&lt;std::string, std::string&gt; output = pi.callFunction(myModulePath, myFuncName, inputArg1, inputArg2, inputArg3);
  </code></pre>
  
  <p>However, this error is thrown (shortened with <code>...</code> for readability):</p>
  
  <p><code>conversion from 'const std::tuple&lt;&gt;' to non-scalar type 'const std::tuple&lt;std::__cxx11::basic_string&lt;...&gt;, std::__cxx11::basic_string&lt;...&gt; &gt;' requested</code></p>
  
  <p>As far as I'm aware <a href="https://stackoverflow.com/a/15043549/5209610">using two variadic templates is legal</a>. Additionally, it seems to me that the return type is explicitly set by the variable (<code>const std::tuple&lt;std::string, std::string&gt; output</code>) I am attempting to assign the result of the function to, so the compiler should know what the desired return 
  type is. </p>
  
  <p>Originally, I thought that the error simply indicated that I wasn't using the variadic templates appropriately. I tried using nested template parameters (illustrated <a href="https://stackoverflow.com/a/12782697/5209610">here</a>) to specify the return type (i.e., <code>const T&lt;Outputs...&gt;&amp; callFunction</code>). However, this only succeeded in producing an error message indicating that template deduction of <code>T</code> had failed.</p>
  
  <p>This error indicates that my intuition is wrong and that, in my original function, the compiler isn't deducing the desired return type from <code>output</code>'s type.</p>
  
  <p>Why is my intuition wrong? How do I correctly use a variadic template to specify this function's return type?</p>