title: Could not infer template argument when using "typename Container::value_type" as the return value
body: <p>First define a generic function whose purpose is to execute a function for a list of inputs, and print out each input and the corresponding function execution result.</p>
  
  <p>In the following, <code>func</code> is a reference to a function, <code>funcName</code> is just the function name for terminal display, <code>inputs</code> are arguments for <code>func</code>.</p>
  
  <pre><code>#define TBOLD(x) "\x1B[1m" x __RST
  #define TRED(x) __KRED x __RST
  
  template&lt;typename ...TInputs, typename TOutput&gt;
  void test_func(TOutput func(TInputs &amp;...), 
          const string &amp;funcName, 
          vector&lt;tuple&lt;TInputs...&gt;&gt; inputs,
          const string &amp;resultDelimiter = ", ")
  {
      cout &lt;&lt; funcName &lt;&lt; endl;
      if (is_same&lt;TOutput, bool&gt;::value)
          cout &lt;&lt; boolalpha;
  
      for (auto &amp;input: inputs)
      {
          auto arg_idx = 0;
          apply([&amp;arg_idx](auto &amp;&amp;... args)
                { ((std::cout &lt;&lt; args &lt;&lt; (++arg_idx == sizeof...(TInputs) ? TBOLD(TRED(" : ")) : ", ")), ...); }, input);
          cout &lt;&lt; apply(func, input) &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p>Now suppose I have the following functions,</p>
  
  <pre><code>static int func1(vector&lt;int&gt; &amp;arr, int &amp;k)
  {
      sort(arr.begin(),arr.end());
      return arr[k];
  }
  
  template&lt;typename Container&gt;
  static typename Container::value_type func2(Container &amp;arr, int &amp;k)
  {
      sort(arr.begin(),arr.end());
      return arr[k];
  }
  </code></pre>
  
  <p>Now the following line will compile,</p>
  
  <pre><code>test_func(func1,"func1",vector&lt;tuple&lt;vector&lt;int&gt;,int&gt;&gt;{make_tuple(vector&lt;int&gt;{3,5,1,2,4},2)})
  </code></pre>
  
  <p>but the following <strong>won't compile</strong> and gives a message that "<strong>could not infer template argument TOutput</strong>". In my opinion, this should have provided enough information to infer the output type <code>TOutput</code>: the <code>inputs</code> argument is of type <code>vector&lt;tuple&lt;vector&lt;int&gt;,int&gt;&gt;</code>, then it should know <code>TInputs...</code> is <code>&lt;Container, int&gt;</code>, and then <code>TOutput</code> is <code>Container::value_type</code>. </p>
  
  <pre><code>test_func(func2,"func2",vector&lt;tuple&lt;vector&lt;int&gt;,int&gt;&gt;{make_tuple(vector&lt;int&gt;{3,5,1,2,4},2)})
  </code></pre>
  
  <p>If this is indeed not working, <strong>what is the right way to make the return type correctly recognized, while preserving the "generality"</strong> of this <code>test_func</code> to accept functions of different arguments and output?</p>