title: Passing a std::shared_ptr to a function object to std::thread
body: <p>Need to have this Functor live as long as my thread does, so I've created a shared_ptr to it and trying to pass it to std::thread. I've copied the code and list of errors here.</p>
  
  <pre><code>struct Functor
  {
      std::string greeting;
      explicit Functor(std::string _greeting="Hello!"): greeting { _greeting }     {}
      void operator()()
      {
          std::cout &lt;&lt; greeting &lt;&lt; "\n";
      }
  };
  
  auto main() -&gt;int 
  {
      std::shared_ptr&lt;Functor&gt; fp = std::make_shared&lt;Functor&gt; ();
      std::thread t(&amp;fp);
      t.join();
      return 0;
  }
  </code></pre>
  
  <p>List of errors:</p>
  
  <pre><code>Error   C2893   Failed to specialize function template 'unknown-type std::invoke(_Callable &amp;&amp;,_Types &amp;&amp;...)'    std_threads C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\thr\xthread  240 
  Error   C2672   'std::invoke': no matching overloaded function found    std_threads C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\thr\xthread  240 
  </code></pre>
  
  <p>I'm new to c++11 and concurrency. Please help me understand the following</p>
  
  <p>1>does a std::thread always invoke the operator() inside an object when passed by value ? If so, why it has been defined so.</p>
  
  <p>2>how to ensure that a resource given to a thread stays around as long as the thread does?</p>
  
  <p>3>is the <i>Functor</i> written here, a function object ?</p>
  
  <p>4>What have I done here in this code ?!</p>