title: c++11 template class return type
body: <p>a simple class</p>
  <pre><code>   struct Test{
          void display(int x)
          {
             printf(&quot;%d\n&quot;, x);
          }
      };
  </code></pre>
  <p>c++11</p>
  <pre><code>template&lt;class F, class... Args&gt;
  auto enqueue(F&amp;&amp; f, Args&amp;&amp;... args) -&gt; std::future&lt;decltype(f(args...))&gt;{
  
      auto task = std::make_shared&lt;std::packaged_task&lt;decltype(f(args...)())&gt;&gt;(
          std::bind(std::forward&lt;F&gt;(f), std::forward&lt;Args&gt;(args)...)
      );
      return task-&gt;get_future();
  }
  </code></pre>
  <p>call it just use (cls is the object of the class of the template function above)</p>
  <pre><code>Test test;
  cls-&gt;enqueue(&amp;Test::display, &amp;test, 0);
  </code></pre>
  <p>the comipler error</p>
  <pre><code>candidate template ignored: substitution failure 
  [with F = void (TestMem::*)(int), Rest = &lt;TestMem *, int&gt;]: called object type 'void (TestMem::*)(int)' is not a function or function pointer
          auto enqueue(F &amp;&amp; f, Rest&amp;&amp;... rest) -&gt;std::future&lt;decltype(f(rest...))&gt; {
  </code></pre>
  <p>above works well on a non class member function, can some one give a fix on c++11</p>
  <p>c++14 works fine, but my project needs c++11</p>
  <pre><code>template&lt;class F, class... Args&gt;
  auto enqueue(F&amp;&amp; f, Args&amp;&amp;... args) {
  
      using return_type = typename std::result_of&lt;F(Args...)&gt;::type;
  
      auto task = std::make_shared&lt;std::packaged_task&lt;return_type()&gt;&gt;(
          std::bind(std::forward&lt;F&gt;(f), std::forward&lt;Args&gt;(args)...)
      );
      return task-&gt;get_future();
  }
  </code></pre>