title: C++ return function lock_guard
body: <p>I have the resource "resource" that wrapped in shared_ptr, and I want to access it from other threads.
  When I do this:</p>
  
  <pre><code>// foo.h
  class Foo{
  public:
      std::shared_ptr&lt;Setup&gt; GetSomeThing();
      void SetSomeThing();
  private:
      std::shared_ptr&lt;Setup&gt; resource;
      std::mutex lock;
  }
  //Foo.cpp
  std::shared_ptr&lt;Setup&gt; Foo::GetSomeThing()
  {
      std::lock_guard&lt;std::mutex&gt; lock (mutex);
      return resource;
  }
  
  void Foo::SetSomeThing()
  {
       std::lock_guard&lt;std::mutex&gt; lock (mutex);
       resource = ...;
  }
  </code></pre>
  
  <p>is it all ok?
  When will be created a return object and when will be destroyed the lock? Is there something about it in the documentation? 
  Thank you!</p>