title: Is there some trick that would allow me to pass stream manipulators to a variadic template function?
body: <p>I've been trying to write a thread-safe wrapper for std::cout and figured it's a good time to learn me some variadic templates.</p>
  
  <p><a href="http://i0.kym-cdn.com/photos/images/original/000/557/347/19f.gif">Like that.</a></p>
  
  <p>Then, just when I thought I got it right, I noticed it doesn't work with std::endl.</p>
  
  <p>Take this code:</p>
  
  <pre><code>template &lt;typename... P&gt;
  void f(P...){}
  
  int main()
  {
      f(1,2,3,std::endl);
  }
  </code></pre>
  
  <p>When you try to compile it, GCC complains in a very silly way:</p>
  
  <pre><code>main.cpp:18:19: error: too many arguments to function 'void f(P ...) [with P = {}]'
  </code></pre>
  
  <p>When you try that with a regular template, you get</p>
  
  <pre><code>main.cpp:22:13: error: no matching function for call to 'f(&lt;unresolved overloaded function type&gt;)'
  </code></pre>
  
  <p>which actually makes sense.</p>
  
  <p>It's not a big issue for me, I can do it in some other way, but I'd really like to know if there's a way to go around that limitation.</p>