]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | * Copyright Andrey Semashev 2007 - 2014. | |
3 | * Distributed under the Boost Software License, Version 1.0. | |
4 | * (See accompanying file LICENSE_1_0.txt or copy at | |
5 | * http://www.boost.org/LICENSE_1_0.txt) | |
6 | */ | |
7 | /*! | |
8 | * \file null_deleter.hpp | |
9 | * \author Andrey Semashev | |
10 | * \date 22.04.2007 | |
11 | * | |
12 | * This header contains a \c null_deleter implementation. This is an empty | |
13 | * function object that receives a pointer and does nothing with it. | |
14 | * Such empty deletion strategy may be convenient, for example, when | |
15 | * constructing <tt>shared_ptr</tt>s that point to some object that should not be | |
16 | * deleted (i.e. a variable on the stack or some global singleton, like <tt>std::cout</tt>). | |
17 | */ | |
18 | ||
19 | #ifndef BOOST_CORE_NULL_DELETER_HPP | |
20 | #define BOOST_CORE_NULL_DELETER_HPP | |
21 | ||
22 | #include <boost/config.hpp> | |
23 | ||
24 | #ifdef BOOST_HAS_PRAGMA_ONCE | |
25 | #pragma once | |
26 | #endif | |
27 | ||
28 | namespace boost { | |
29 | ||
30 | //! A function object that does nothing and can be used as an empty deleter for \c shared_ptr | |
31 | struct null_deleter | |
32 | { | |
33 | //! Function object result type | |
34 | typedef void result_type; | |
35 | /*! | |
36 | * Does nothing | |
37 | */ | |
38 | template< typename T > | |
39 | void operator() (T*) const BOOST_NOEXCEPT {} | |
40 | }; | |
41 | ||
42 | } // namespace boost | |
43 | ||
44 | #endif // BOOST_CORE_NULL_DELETER_HPP |