title: c++ can a temporary lambda be passed by reference (works on msvc/windows but not gcc/linux)?
body: <p>Lets say I have the following code snippets:</p>
  
  <pre><code>// global variable
  std::thread worker_thread;
  
  // Template function
  template &lt;typename Functor&gt;
  void start_work(Functor &amp;worker_fn)  // lambda passed by ref
  {
      worker_thread = std::thread([&amp;](){
          worker_fn();
      });
  }
  </code></pre>
  
  <p>This is called like this:</p>
  
  <pre><code>void do_work(int value)
  {
      printf("Hello from worker\r\n");
  }
  
  int main()
  {
      // This lambda is a temporary variable...
      start_work([do_work](int value){ do_work(value) });
  }
  </code></pre>
  
  <p>I started developing on MSVC2012. This all compiled up fine and seemed to work. However when I moved onto the gcc compiler on Linux platform I got the following (abbreviated) error:</p>
  
  <p><code>no known conversion for argument 1 '...__lambda3' to '...__lambda3&amp;'</code></p>
  
  <p><strong>My Questions:</strong></p>
  
  <ul>
  <li>So, from the error I assume that the lambda was a temporary variable and it therefore can't be passed by reference - is that right?</li>
  <li>Also - any idea why this would work with MSVC? - is it auto-fixing what I wrote?</li>
  </ul>