File indexing completed on 2025-01-18 09:40:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_MOVE_DEFAULT_DELETE_HPP_INCLUDED
0012 #define BOOST_MOVE_DEFAULT_DELETE_HPP_INCLUDED
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017 #
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 # pragma once
0020 #endif
0021
0022 #include <boost/move/detail/config_begin.hpp>
0023 #include <boost/move/detail/workaround.hpp>
0024 #include <boost/move/detail/unique_ptr_meta_utils.hpp>
0025 #include <boost/move/utility_core.hpp>
0026
0027 #include <cstddef> //For std::size_t,std::nullptr_t
0028
0029
0030
0031
0032 namespace boost{
0033
0034 namespace move_upd {
0035
0036 namespace bmupmu = ::boost::move_upmu;
0037
0038
0039
0040
0041
0042
0043
0044
0045 template<class U, class T>
0046 struct def_del_compatible_cond
0047 : bmupmu::is_convertible<U*, T*>
0048 {};
0049
0050 template<class U, class T, std::size_t N>
0051 struct def_del_compatible_cond<U[N], T[]>
0052 : def_del_compatible_cond<U[], T[]>
0053 {};
0054
0055 template<class U, class T, class Type = bmupmu::nat>
0056 struct enable_def_del
0057 : bmupmu::enable_if_c<def_del_compatible_cond<U, T>::value, Type>
0058 {};
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 template<class U, class T, class Type = bmupmu::nat>
0069 struct enable_defdel_call
0070 : public enable_def_del<U, T, Type>
0071 {};
0072
0073 template<class U, class T, class Type>
0074 struct enable_defdel_call<U, T[], Type>
0075 : public enable_def_del<U[], T[], Type>
0076 {};
0077
0078 template<class U, class T, class Type, std::size_t N>
0079 struct enable_defdel_call<U, T[N], Type>
0080 : public enable_def_del<U[N], T[N], Type>
0081 {};
0082
0083
0084
0085
0086
0087 struct bool_conversion {int for_bool; int for_arg(); };
0088 typedef int bool_conversion::* explicit_bool_arg;
0089
0090 #if !defined(BOOST_NO_CXX11_NULLPTR) && !defined(BOOST_NO_CXX11_DECLTYPE)
0091 typedef decltype(nullptr) nullptr_type;
0092 #elif !defined(BOOST_NO_CXX11_NULLPTR)
0093 typedef std::nullptr_t nullptr_type;
0094 #else
0095 typedef int (bool_conversion::*nullptr_type)();
0096 #endif
0097
0098 template<bool B>
0099 struct is_array_del
0100 {};
0101
0102 template<class T>
0103 void call_delete(T *p, is_array_del<true>)
0104 {
0105 delete [] p;
0106 }
0107
0108 template<class T>
0109 void call_delete(T *p, is_array_del<false>)
0110 {
0111 delete p;
0112 }
0113
0114 template< class T, class U
0115 , bool enable = def_del_compatible_cond< U, T>::value &&
0116 !move_upmu::is_array<T>::value &&
0117 !move_upmu::is_same<typename move_upmu::remove_cv<T>::type, void>::value &&
0118 !move_upmu::is_same<typename move_upmu::remove_cv<U>::type, typename move_upmu::remove_cv<T>::type>::value
0119 >
0120 struct missing_virtual_destructor_default_delete
0121 { static const bool value = !move_upmu::has_virtual_destructor<T>::value; };
0122
0123 template<class T, class U>
0124 struct missing_virtual_destructor_default_delete<T, U, false>
0125 { static const bool value = false; };
0126
0127
0128
0129
0130
0131 template<class Deleter, class U>
0132 struct missing_virtual_destructor
0133 { static const bool value = false; };
0134
0135 template<class T, class U>
0136 struct missing_virtual_destructor< ::boost::movelib::default_delete<T>, U >
0137 : missing_virtual_destructor_default_delete<T, U>
0138 {};
0139
0140
0141 }
0142
0143
0144 namespace movelib {
0145
0146 namespace bmupd = boost::move_upd;
0147 namespace bmupmu = ::boost::move_upmu;
0148
0149
0150
0151
0152
0153 template <class T>
0154 struct default_delete
0155 {
0156
0157
0158 BOOST_CONSTEXPR default_delete()
0159
0160 #if !defined(BOOST_GCC) || (BOOST_GCC < 40600 && BOOST_GCC >= 40700) || defined(BOOST_MOVE_DOXYGEN_INVOKED)
0161 BOOST_NOEXCEPT
0162 #endif
0163 #if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || defined(BOOST_MOVE_DOXYGEN_INVOKED)
0164 = default;
0165 #else
0166 {};
0167 #endif
0168
0169 #if defined(BOOST_MOVE_DOXYGEN_INVOKED)
0170
0171
0172 default_delete(const default_delete&) BOOST_NOEXCEPT = default;
0173
0174
0175 default_delete &operator=(const default_delete&) BOOST_NOEXCEPT = default;
0176 #else
0177 typedef typename bmupmu::remove_extent<T>::type element_type;
0178 #endif
0179
0180
0181
0182
0183
0184
0185 template <class U>
0186 default_delete(const default_delete<U>&
0187 BOOST_MOVE_DOCIGN(BOOST_MOVE_I typename bmupd::enable_def_del<U BOOST_MOVE_I T>::type* =0)
0188 ) BOOST_NOEXCEPT
0189 {
0190
0191
0192 BOOST_MOVE_STATIC_ASSERT(( !bmupd::missing_virtual_destructor<default_delete, U>::value ));
0193 }
0194
0195
0196
0197
0198
0199
0200 template <class U>
0201 BOOST_MOVE_DOC1ST(default_delete&,
0202 typename bmupd::enable_def_del<U BOOST_MOVE_I T BOOST_MOVE_I default_delete &>::type)
0203 operator=(const default_delete<U>&) BOOST_NOEXCEPT
0204 {
0205
0206
0207 BOOST_MOVE_STATIC_ASSERT(( !bmupd::missing_virtual_destructor<default_delete, U>::value ));
0208 return *this;
0209 }
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219 template <class U>
0220 BOOST_MOVE_DOC1ST(void, typename bmupd::enable_defdel_call<U BOOST_MOVE_I T BOOST_MOVE_I void>::type)
0221 operator()(U* ptr) const BOOST_NOEXCEPT
0222 {
0223
0224 BOOST_MOVE_STATIC_ASSERT(sizeof(U) > 0);
0225
0226
0227 BOOST_MOVE_STATIC_ASSERT(( !bmupd::missing_virtual_destructor<default_delete, U>::value ));
0228 element_type * const p = static_cast<element_type*>(ptr);
0229 move_upd::call_delete(p, move_upd::is_array_del<bmupmu::is_array<T>::value>());
0230 }
0231
0232
0233
0234 void operator()(BOOST_MOVE_DOC0PTR(bmupd::nullptr_type)) const BOOST_NOEXCEPT
0235 { BOOST_MOVE_STATIC_ASSERT(sizeof(element_type) > 0); }
0236 };
0237
0238 }
0239 }
0240
0241 #include <boost/move/detail/config_end.hpp>
0242
0243 #endif