Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:42

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 ) BOOST_SP_NOEXCEPT: d_( d )
0042     {
0043     }
0044 
0045 #if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
0046 
0047     explicit local_sp_deleter( D&& d ) BOOST_SP_NOEXCEPT: d_( std::move(d) )
0048     {
0049     }
0050 
0051 #endif
0052 
0053     D& deleter() BOOST_SP_NOEXCEPT
0054     {
0055         return d_;
0056     }
0057 
0058     template<class Y> void operator()( Y* p ) BOOST_SP_NOEXCEPT
0059     {
0060         d_( p );
0061     }
0062 
0063 #if !defined( BOOST_NO_CXX11_NULLPTR )
0064 
0065     void operator()( boost::detail::sp_nullptr_t p ) BOOST_SP_NOEXCEPT
0066     {
0067         d_( p );
0068     }
0069 
0070 #endif
0071 };
0072 
0073 template<> class local_sp_deleter<void>
0074 {
0075 };
0076 
0077 template<class D> D * get_local_deleter( local_sp_deleter<D> * p ) BOOST_SP_NOEXCEPT
0078 {
0079     return &p->deleter();
0080 }
0081 
0082 inline void * get_local_deleter( local_sp_deleter<void> * /*p*/ ) BOOST_SP_NOEXCEPT
0083 {
0084     return 0;
0085 }
0086 
0087 } // namespace detail
0088 
0089 } // namespace boost
0090 
0091 #endif  // #ifndef BOOST_SMART_PTR_DETAIL_LOCAL_SP_DELETER_HPP_INCLUDED