]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/index/detail/rtree/node/scoped_deallocator.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / geometry / index / detail / rtree / node / scoped_deallocator.hpp
1 // Boost.Geometry Index
2 //
3 // R-tree scoped deallocator
4 //
5 // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
6 //
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP
12 #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP
13
14 namespace boost { namespace geometry { namespace index {
15
16 namespace detail { namespace rtree {
17
18 template <typename Alloc>
19 class scoped_deallocator
20 {
21 scoped_deallocator(scoped_deallocator const&);
22 scoped_deallocator & operator=(scoped_deallocator const&);
23 public:
24 typedef typename Alloc::pointer pointer;
25 inline scoped_deallocator(pointer p, Alloc & a)
26 : m_ptr(p), m_alloc(a)
27 {}
28 inline ~scoped_deallocator()
29 {
30 if ( m_ptr )
31 {
32 boost::container::allocator_traits<Alloc>::deallocate(m_alloc, m_ptr, 1);
33 }
34 }
35 inline void release()
36 {
37 m_ptr = 0;
38 }
39 private:
40 pointer m_ptr;
41 Alloc & m_alloc;
42 };
43
44 }} // namespace detail::rtree
45
46 }}} // namespace boost::geometry::index
47
48 #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP