title: Calling a object function in boost scope exit
body: <p>I have the following piece of code:
  How do I call a member function in scope exit.</p>
  
  <pre><code>class A
  {
  public:
      void foo();
      void bar();
  };
  
  void A::foo() 
  {
      BOOST_SCOPE_EXIT(void)
      {
          bar(); // Does not compile
      }
      BOOST_SCOPE_EXIT_END
  }
  
  void A::bar() {}
  
  void foo4()
  {
      A a;    
      a.foo();
  } 
  </code></pre>
  
  <p>Err message</p>
  
  <pre><code>boost_scope_exit.cpp: In static member function ‘static void  
  A::foo()::boost_se_guard_t_71::boost_se_body()’:
  boost_scope_exit.cpp:73:13: error: cannot call member function ‘void          
  A::bar()’ without object
       bar(); // Does not compile
           ^
  </code></pre>
  
  <p>How can I call a member function from scope exit. </p>
  
  <p>Found a answer in the boost documentation:</p>
  
  <p><a href="http://www.boost.org/doc/libs/1_56_0/libs/scope_exit/doc/html/scope_exit/tutorial.html" rel="nofollow">Boost docs</a></p>
  
  <p>Just search for "Capturing The Object this"</p>