]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | #ifndef BOOST_SMART_PTR_DETAIL_LOCAL_SP_DELETER_HPP_INCLUDED |
2 | #define BOOST_SMART_PTR_DETAIL_LOCAL_SP_DELETER_HPP_INCLUDED | |
3 | ||
4 | // MS compatible compilers support #pragma once | |
5 | ||
6 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) | |
7 | # pragma once | |
8 | #endif | |
9 | ||
10 | // detail/local_sp_deleter.hpp | |
11 | // | |
12 | // Copyright 2017 Peter Dimov | |
13 | // | |
14 | // Distributed under the Boost Software License, Version 1.0. (See | |
15 | // accompanying file LICENSE_1_0.txt or copy at | |
16 | // http://www.boost.org/LICENSE_1_0.txt) | |
17 | // | |
18 | // See http://www.boost.org/libs/smart_ptr/ for documentation. | |
19 | ||
20 | #include <boost/smart_ptr/detail/local_counted_base.hpp> | |
21 | #include <boost/config.hpp> | |
22 | ||
23 | namespace boost | |
24 | { | |
25 | ||
26 | namespace detail | |
27 | { | |
28 | ||
29 | template<class D> class local_sp_deleter: public local_counted_impl_em | |
30 | { | |
31 | private: | |
32 | ||
33 | D d_; | |
34 | ||
35 | public: | |
36 | ||
37 | local_sp_deleter(): d_() | |
38 | { | |
39 | } | |
40 | ||
41 | explicit local_sp_deleter( D const& d ) BOOST_SP_NOEXCEPT: d_( d ) | |
42 | { | |
43 | } | |
44 | ||
45 | #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) | |
46 | ||
47 | explicit local_sp_deleter( D&& d ) BOOST_SP_NOEXCEPT: d_( std::move(d) ) | |
48 | { | |
49 | } | |
50 | ||
51 | #endif | |
52 | ||
92f5a8d4 | 53 | D& deleter() BOOST_SP_NOEXCEPT |
b32b8144 FG |
54 | { |
55 | return d_; | |
56 | } | |
57 | ||
58 | template<class Y> void operator()( Y* p ) BOOST_SP_NOEXCEPT | |
59 | { | |
60 | d_( p ); | |
61 | } | |
62 | ||
63 | #if !defined( BOOST_NO_CXX11_NULLPTR ) | |
64 | ||
65 | void operator()( boost::detail::sp_nullptr_t p ) BOOST_SP_NOEXCEPT | |
66 | { | |
67 | d_( p ); | |
68 | } | |
69 | ||
70 | #endif | |
71 | }; | |
72 | ||
73 | template<> class local_sp_deleter<void> | |
74 | { | |
75 | }; | |
76 | ||
92f5a8d4 | 77 | template<class D> D * get_local_deleter( local_sp_deleter<D> * p ) BOOST_SP_NOEXCEPT |
b32b8144 FG |
78 | { |
79 | return &p->deleter(); | |
80 | } | |
81 | ||
92f5a8d4 | 82 | inline void * get_local_deleter( local_sp_deleter<void> * /*p*/ ) BOOST_SP_NOEXCEPT |
b32b8144 FG |
83 | { |
84 | return 0; | |
85 | } | |
86 | ||
87 | } // namespace detail | |
88 | ||
89 | } // namespace boost | |
90 | ||
91 | #endif // #ifndef BOOST_SMART_PTR_DETAIL_LOCAL_SP_DELETER_HPP_INCLUDED |