title: Passing references to Variadic templates
body: <p>I'm working on an Event library and I'm facing a problem with Variadic templates.</p>
  
  <p>All is working very nice except the fact that I can't pass references as parameters...</p>
  
  <p>Here is a very simplified example wrote to expose my problem.</p>
  
  <pre><code>struct DelayedSignal 
  {   
      ~DelayedSignal ()
      { std::cout &lt;&lt; "~DelayedSignal CLOSE" &lt;&lt; std::endl; }
  
      template&lt;class C, class... Args&gt;
      DelayedSignal ( void(C::*func)(Args...), C&amp; obj )
      { std::cout &lt;&lt; "DelayedSignal INIT - 03 - pointer to method &amp; pointer to class instance (Arg num: " &lt;&lt; sizeof...(Args) &lt;&lt; ")" &lt;&lt; std::endl; }
  
      template&lt;class C, class... Args&gt;
      DelayedSignal ( void(C::*func)(Args...), C&amp; obj, Args... args )
      {
          std::cout &lt;&lt; "DelayedSignal INIT - 04 - pointer to method &amp; pointer to class instance &amp; arguments (Arg num: " &lt;&lt; sizeof...(Args) &lt;&lt; ")" &lt;&lt; std::endl;
      }
  };
  
  template&lt;class... ArgsBis&gt;
  struct DelayedSignal_DebugHelper 
  {
      ~DelayedSignal_DebugHelper ()
      { std::cout &lt;&lt; "~DelayedSignal_DebugHelper CLOSE" &lt;&lt; std::endl; }
  
      template&lt;class C, class... Args&gt;
      DelayedSignal_DebugHelper ( void(C::*func)(Args...), C&amp; obj )
      { std::cout &lt;&lt; "DelayedSignal_DebugHelper INIT - 03 - pointer to method &amp; pointer to class instance (Arg num: " &lt;&lt; sizeof...(Args) &lt;&lt; ")" &lt;&lt; std::endl; }
  
      template&lt;class C, class... Args&gt;
      DelayedSignal_DebugHelper ( void(C::*func)(Args...), C&amp; obj, ArgsBis... args ) // Need to use ArgsBis instead of Args to make it work
      {
          std::cout &lt;&lt; "DelayedSignal_DebugHelper INIT - 04 - pointer to method &amp; pointer to class instance &amp; arguments (Arg num: " &lt;&lt; sizeof...(Args) &lt;&lt; ")" &lt;&lt; std::endl;
      }
  };
  
  
  template &lt; class Tr, class... Args &gt;
  struct Signal
  {
      void fire ( Args... args ) { std::cout &lt;&lt; "Signal::fire::" &lt;&lt; sizeof...(Args) &lt;&lt; std::endl; }
  };
  
  struct Klass {};
  
  
  int main()
  {
      std::string str1("Blop");   // Will be used as reference
      Klass k;                    // Will be used as reference
  
      Signal&lt;void, Klass&amp;&gt; signal_01;
      Signal&lt;void, std::string&amp;&gt; signal_02;
  
      std::cout &lt;&lt; "====== DelayedSignal :: needed for production purpose ===============" &lt;&lt; std::endl;
  
      // OK
      DelayedSignal test01(&amp;Signal&lt;void, std::string&amp;&gt;::fire, signal_02);
      // HERE IS THE PROBLEM
      //DelayedSignal test02(&amp;Signal&lt;void, std::string&amp;&gt;::fire, signal_02, str1);
  
      // OK
      DelayedSignal test03(&amp;Signal&lt;void, Klass&amp;&gt;::fire, signal_01);
      // HERE IS THE PROBLEM
      //DelayedSignal test04(&amp;Signal&lt;void, Klass&amp;&gt;::fire, signal_01, k);
  
      std::cout &lt;&lt; "====== DelayedSignal_DebugHelper :: used only for debug purpose ======" &lt;&lt; std::endl;
  
      // OK
      DelayedSignal_DebugHelper&lt;std::string&amp;&gt; test05(&amp;Signal&lt;void, std::string&amp;&gt;::fire, signal_02);
      // OK
      DelayedSignal_DebugHelper&lt;std::string&amp;&gt; test06(&amp;Signal&lt;void, std::string&amp;&gt;::fire, signal_02, str1);
  
      // OK
      DelayedSignal_DebugHelper&lt;Klass&amp;&gt; test07(&amp;Signal&lt;void, Klass&amp;&gt;::fire, signal_01);
      // OK
      DelayedSignal_DebugHelper&lt;Klass&amp;&gt; test08(&amp;Signal&lt;void, Klass&amp;&gt;::fire, signal_01, k);
  
      return 1;
  }
  </code></pre>
  
  <p>As I register all DelayedSignal instances into a single std::list instance I would like to avoid using template on the class itself, and that's why I use templates on the constructors instead. I could also use a pure virtual class as base for all DelayedSignal and register pointers to the virtual class into the std::list but I think it's best to minimize the use of virtual methods and I'm really intrigued by this problem...</p>
  
  <p>As you can see in this example, test02 and test04 return errors if they are activated.
  DelayedSignal_DebugHelper is almost identical to DelayedSignal except the fact that it use ArgsBis (a class template argument) on the last constructor instead of the Args template (the method template argument), else it doesn't work (as with DelayedSignal). Args is accepted on the <code>void(C::*func)(Args...)</code> but is not with <code>ArgsBis... args</code> dispite the fact they are in the same constructor declaration.</p>
  
  <p>As far as I know, there is no problem without references (<code>DelayedSignal test04(&amp;Signal&lt;void, Klass&gt;::fire, signal_01, k);</code> for instance) or with multiple parameters (or none) as long as there is no references.</p>
  
  <p>Is there anyway to fix this problem ?</p>
  
  <p>Thank you.</p>