KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
l_scope_guard.h
Go to the documentation of this file.
1 /* $Id: l_scope_guard.h 14082 2013-03-12 18:32:12Z jguan1 $ */
2 /* {{{=========================================================================== *
3  |
4  | Copyright (c) 1994-2012 by Kobus Barnard (author)
5  |
6  | Personal and educational use of this code is granted, provided that this
7  | header is kept intact, and that the authorship is not misrepresented, that
8  | its use is acknowledged in publications, and relevant papers are cited.
9  |
10  | For other use contact the author (kobus AT cs DOT arizona DOT edu).
11  |
12  | Please note that the code in this file has not necessarily been adequately
13  | tested. Naturally, there is no guarantee of performance, support, or fitness
14  | for any particular task. Nonetheless, I am interested in hearing about
15  | problems that you encounter.
16  |
17  | Author: Kyle Simek
18  * =========================================================================== }}}*/
19 
20 // vim: tabstop=4 shiftwidth=4 foldmethod=marker
21 
22 #ifndef KJB_L_CPP_SCOPE_GUARD_H
23 #define KJB_L_CPP_SCOPE_GUARD_H
24 
25 #include <boost/function.hpp>
26 #include <boost/shared_ptr.hpp>
27 #include <boost/bind.hpp>
28 
29 namespace kjb
30 {
31 
42 {
43  Scope_guard(const boost::function0<void>& callback) :
44  on_exit_(
45  static_cast<void*>(0),
46  boost::bind(callback))
47  {}
48 
49  boost::shared_ptr<void> on_exit_;
50 };
51 
52 } // namespace kjb;
53 
54 #endif
boost::shared_ptr< void > on_exit_
Definition: l_scope_guard.h:49
Definition: l_scope_guard.h:41
Scope_guard(const boost::function0< void > &callback)
Definition: l_scope_guard.h:43