1/////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright Ion Gaztanaga 2014-2014
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9// See http://www.boost.org/libs/intrusive for documentation.
10//
11/////////////////////////////////////////////////////////////////////////////
12
13#ifndef BOOST_INTRUSIVE_DETAIL_EXCEPTION_DISPOSER_HPP
14#define BOOST_INTRUSIVE_DETAIL_EXCEPTION_DISPOSER_HPP
15
16#ifndef BOOST_CONFIG_HPP
17# include <boost/config.hpp>
18#endif
19
20#if defined(BOOST_HAS_PRAGMA_ONCE)
21# pragma once
22#endif
23
24#include <boost/intrusive/detail/workaround.hpp>
25
26namespace boost {
27namespace intrusive {
28namespace detail {
29
30template<class Container, class Disposer>
31class exception_disposer
32{
33 Container *cont_;
34 Disposer &disp_;
35
36 exception_disposer(const exception_disposer&);
37 exception_disposer &operator=(const exception_disposer&);
38
39 public:
40 exception_disposer(Container &cont, Disposer &disp)
41 : cont_(&cont), disp_(disp)
42 {}
43
44 inline void release()
45 { cont_ = 0; }
46
47 ~exception_disposer()
48 {
49 if(cont_){
50 cont_->clear_and_dispose(disp_);
51 }
52 }
53};
54
55} //namespace detail{
56} //namespace intrusive{
57} //namespace boost{
58
59#endif //BOOST_INTRUSIVE_DETAIL_EXCEPTION_DISPOSER_HPP
60

source code of boost/libs/intrusive/include/boost/intrusive/detail/exception_disposer.hpp