title: Using std::move to pass in a temp lambda, or to "pull" out a temp parameter and what is the difference?
body: <p>I have the following (contrived) code where I have a printer class with a single print function in it and a working class that processes a string and then calls a callback function to the print function:</p>
  
  <pre><code>#include &lt;functional&gt;
  #include &lt;iostream&gt;
  
  using callback_fn = std::function&lt;bool(std::string)&gt;;
  
  class printer
  {
  public:   
      bool print(std::string data)
      {
          std::cout &lt;&lt; data &lt;&lt; std::endl;
          return true;
      }
  };
  
  class worker
  {
  public:   
      callback_fn m_callback;
      void set_callback(callback_fn callback)
      {
          m_callback = std::move(callback);  // &lt;-- 1. callback is a temp, so what does std::move do here?
      }
      void process_data(std::string data)
      {
          if (!m_callback(data)) { /* do error handling */ }
      }
  };
  
  int main() {
      printer p;
      worker w;
  
      w.set_callback( std::move([&amp;](std::string s){ return p.print(s); }) ); // &lt;-- 2. what does std::move do here?
      w.process_data("hello world2");
  }
  </code></pre>
  
  <p><strong>Note:</strong> I have <code>std:: move()</code> called twice... now this works (surprisingly to me) but I have both only to show what I am trying. My questions are:</p>
  
  <ol>
  <li>Should I use <code>std::move()</code> in the <code>set_callback()</code> function to "pull" out the temp, and if I use this is there really a copy or does <code>std:: move(</code>) mean that its not really a copy?</li>
  <li>Should I use <code>std:: move()</code> to pass in the lambda... and is that even correct.</li>
  <li>I guess I don't understand why this code works with two <code>std:: moves()</code>... which implies that I still don't understand what <code>std:: move()</code> is doing  - so if someone can elighten me on what is going on here that would be great!</li>
  <li>I know that I can pass by value, but my goal is to move the temp so that I don't have a copy of it. Is that what is meant by <em>perfect forwarding</em>?</li>
  </ol>
  
  <p>My example can be seen here in wandbox: <a href="https://wandbox.org/permlink/rJDudtg602Ybhnzi" rel="nofollow noreferrer">https://wandbox.org/permlink/rJDudtg602Ybhnzi</a></p>
  
  <p><strong>UPDATE</strong>
  The reason for me trying to use std::move was to avoid copying the lambda around. (I think that is called forwarding/perfect-forwarding)...but I think I am making a hash of it!</p>