title: How can std::function's target be accessed?
body: <p>I'm trying to compare the function pointer stored in two std::function objects, declared as <code>std::function&lt;void(Args...)&gt;</code> where <code>Args...</code> is a class template parameter. I intended to do this by comparing the output of target(), but I'm having trouble accessing that value. <strong>What's the correct way access std::function::target()?</strong></p>
  
  <p>Below is a boiled-down version of what I've tried:</p>
  
  <pre><code>#include &lt;functional&gt;
  
  template &lt;typename... Args&gt;
  void check(std::function&lt;void(Args...)&gt; func)
  {
    auto type = func.target&lt;void(*)(Args...)&gt;();
  }
  
  void m() {}
  
  int main()
  {
    auto func = std::function&lt;void()&gt;(m);
    check&lt;&gt;(func);
  }
  </code></pre>
  
  <p>And the output from compiling with <code>g++ -std=c++11 Demo.cpp</code>:</p>
  
  <pre><code>Demo.cpp: In function ‘void check(std::function&lt;void(Args ...)&gt;)’:
  Demo.cpp:6:27: error: expected primary-expression before ‘void’
      6 |   auto type = func.target&lt;void(Args...)&gt;();
        |                           ^~~~
  Demo.cpp:6:27: error: expected ‘,’ or ‘;’ before ‘void’
  </code></pre>