Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:04:54

0001 #ifndef BOOST_SMART_PTR_DETAIL_LOCAL_SP_DELETER_HPP_INCLUDED
0002 #define BOOST_SMART_PTR_DETAIL_LOCAL_SP_DELETER_HPP_INCLUDED
0003 
0004 // MS compatible compilers support #pragma once
0005 
0006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
0007 # pragma once
0008 #endif
0009 
0010 //  detail/local_sp_deleter.hpp
0011 //
0012 //  Copyright 2017 Peter Dimov
0013 //
0014 //  Distributed under the Boost Software License, Version 1.0. (See
0015 //  accompanying file LICENSE_1_0.txt or copy at
0016 //  http://www.boost.org/LICENSE_1_0.txt)
0017 //
0018 //  See http://www.boost.org/libs/smart_ptr/ for documentation.
0019 
0020 #include <boost/smart_ptr/detail/local_counted_base.hpp>
0021 #include <boost/config.hpp>
0022 
0023 namespace boost
0024 {
0025 
0026 namespace detail
0027 {
0028 
0029 template<class D> class local_sp_deleter: public local_counted_impl_em
0030 {
0031 private:
0032 
0033     D d_;
0034 
0035 public:
0036 
0037     local_sp_deleter(): d_()
0038     {
0039     }
0040 
0041     explicit local_sp_deleter( D const& d ) noexcept: d_( d )
0042     {
0043     }
0044 
0045     explicit local_sp_deleter( D&& d ) noexcept: d_( std::move(d) )
0046     {
0047     }
0048 
0049     D& deleter() noexcept
0050     {
0051         return d_;
0052     }
0053 
0054     template<class Y> void operator()( Y* p ) noexcept
0055     {
0056         d_( p );
0057     }
0058 
0059     void operator()( std::nullptr_t p ) noexcept
0060     {
0061         d_( p );
0062     }
0063 };
0064 
0065 template<> class local_sp_deleter<void>
0066 {
0067 };
0068 
0069 template<class D> D * get_local_deleter( local_sp_deleter<D> * p ) noexcept
0070 {
0071     return &p->deleter();
0072 }
0073 
0074 inline void * get_local_deleter( local_sp_deleter<void> * /*p*/ ) noexcept
0075 {
0076     return 0;
0077 }
0078 
0079 } // namespace detail
0080 
0081 } // namespace boost
0082 
0083 #endif  // #ifndef BOOST_SMART_PTR_DETAIL_LOCAL_SP_DELETER_HPP_INCLUDED