title: Is there a C++ standard class to set a variable to a value at scope exit
body: <p>Within the scope of a member function, I want to temporarly set a member variable to a certain value.</p>
  
  <p>Then, when this function returns, I want to reset this member variable to a given known value.</p>
  
  <p>To bo safe against exceptions and multiple returns, and I've done it with a simple RAII like class. It's defined within the scope of the member function.</p>
  
  <pre><code>void MyClass::MyMemberFunction() {
      struct SetBackToFalse {
          SetBackToFalse(bool* p): m_p(p) {}
          ~SetBackToFalse() {*m_p=false;}
      private:
          bool* m_p;
      };
  
      m_theVariableToChange = true;
      SetBackToFalse resetFalse( &amp;m_theVariableToChange ); // Will reset the variable to false.
  
      // Function body that may throw.
  }
  </code></pre>
  
  <p>It seems so obviously commonplace, that I was wondering if there was any such template class doing this in the C++ standard library?</p>