File indexing completed on 2025-01-18 09:50:34
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_MOVE_PTR_DEFAULT_DELETER_HPP_INCLUDED
0012 #define BOOST_MOVE_PTR_DEFAULT_DELETER_HPP_INCLUDED
0013
0014 #include <boost/checked_delete.hpp>
0015 #include <boost/mpl/if.hpp>
0016 #include <boost/type_traits/is_array.hpp>
0017 #include <boost/type_traits/remove_bounds.hpp>
0018
0019 namespace boost { namespace ptr_container_detail { namespace move_ptrs {
0020
0021 namespace ptr_container_detail {
0022
0023 template<typename T>
0024 struct deleter_base {
0025 typedef void (*deleter)(T*);
0026 deleter_base(deleter d) { delete_ = d; }
0027 void operator() (T* t) const { delete_(t); }
0028 static deleter delete_;
0029 };
0030
0031 template<class T>
0032 typename deleter_base<T>::deleter
0033 deleter_base<T>::delete_;
0034
0035 template<typename T>
0036 struct scalar_deleter : deleter_base<T> {
0037 typedef deleter_base<T> base;
0038 scalar_deleter() : base(do_delete) { }
0039 static void do_delete(T* t) { checked_delete(t); }
0040 };
0041
0042 template<typename T>
0043 struct array_deleter
0044 : deleter_base<typename remove_bounds<T>::type>
0045 {
0046 typedef typename remove_bounds<T>::type element_type;
0047 typedef deleter_base<element_type> base;
0048 array_deleter() : base(do_delete) { }
0049 static void do_delete(element_type* t) { checked_array_delete(t); }
0050 };
0051
0052 }
0053
0054 template<typename T>
0055 struct default_deleter
0056 : mpl::if_<
0057 is_array<T>,
0058 ptr_container_detail::array_deleter<T>,
0059 ptr_container_detail::scalar_deleter<T>
0060 >::type
0061 {
0062 default_deleter() { }
0063 template<typename TT>
0064 default_deleter(default_deleter<TT>) { }
0065 };
0066
0067 } } }
0068
0069 #endif