1 // Boost.Geometry Index
3 // R-tree scoped deallocator
5 // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
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)
11 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP
12 #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP
14 namespace boost { namespace geometry { namespace index {
16 namespace detail { namespace rtree {
18 template <typename Alloc>
19 class scoped_deallocator
21 scoped_deallocator(scoped_deallocator const&);
22 scoped_deallocator & operator=(scoped_deallocator const&);
24 typedef typename Alloc::pointer pointer;
25 inline scoped_deallocator(pointer p, Alloc & a)
26 : m_ptr(p), m_alloc(a)
28 inline ~scoped_deallocator()
32 boost::container::allocator_traits<Alloc>::deallocate(m_alloc, m_ptr, 1);
44 }} // namespace detail::rtree
46 }}} // namespace boost::geometry::index
48 #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP