Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:29

0001 // Boost.Geometry Index
0002 //
0003 // R-tree scoped deallocator
0004 //
0005 // Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland.
0006 //
0007 // This file was modified by Oracle on 2021.
0008 // Modifications copyright (c) 2021 Oracle and/or its affiliates.
0009 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0010 //
0011 // Use, modification and distribution is subject to the Boost Software License,
0012 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0013 // http://www.boost.org/LICENSE_1_0.txt)
0014 
0015 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP
0016 #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP
0017 
0018 #include <boost/container/allocator_traits.hpp>
0019 
0020 namespace boost { namespace geometry { namespace index {
0021 
0022 namespace detail { namespace rtree {
0023 
0024 template <typename Alloc>
0025 class scoped_deallocator
0026 {
0027     typedef boost::container::allocator_traits<Alloc> alloc_traits;
0028 
0029     scoped_deallocator(scoped_deallocator const&);
0030     scoped_deallocator & operator=(scoped_deallocator const&);
0031 public:
0032     typedef typename alloc_traits::pointer pointer;
0033 
0034     inline scoped_deallocator(pointer p, Alloc & a)
0035         : m_ptr(p), m_alloc(a)
0036     {}
0037     inline ~scoped_deallocator()
0038     {
0039         if ( m_ptr )
0040         {
0041             alloc_traits::deallocate(m_alloc, m_ptr, 1);
0042         }
0043     }
0044     inline void release()
0045     {
0046         m_ptr = 0;
0047     }
0048 private:
0049     pointer m_ptr;
0050     Alloc & m_alloc;
0051 };
0052 
0053 }} // namespace detail::rtree
0054 
0055 }}} // namespace boost::geometry::index
0056 
0057 #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP