File indexing completed on 2025-06-30 08:09:40
0001 #ifndef BOOST_CORE_CHECKED_DELETE_HPP
0002 #define BOOST_CORE_CHECKED_DELETE_HPP
0003
0004
0005
0006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
0007 # pragma once
0008 #endif
0009
0010 #include <boost/config.hpp>
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 namespace boost
0027 {
0028
0029
0030
0031 template<class T> inline void checked_delete(T * x) BOOST_NOEXCEPT
0032 {
0033 #if defined(__cpp_static_assert) && __cpp_static_assert >= 200410L
0034
0035 static_assert( sizeof(T) != 0, "Type must be complete" );
0036
0037 #else
0038
0039 typedef char type_must_be_complete[ sizeof(T) ];
0040 (void) sizeof(type_must_be_complete);
0041
0042 #endif
0043
0044 delete x;
0045 }
0046
0047 template<class T> inline void checked_array_delete(T * x) BOOST_NOEXCEPT
0048 {
0049 #if defined(__cpp_static_assert) && __cpp_static_assert >= 200410L
0050
0051 static_assert( sizeof(T) != 0, "Type must be complete" );
0052
0053 #else
0054
0055 typedef char type_must_be_complete[ sizeof(T) ];
0056 (void) sizeof(type_must_be_complete);
0057
0058 #endif
0059
0060 delete [] x;
0061 }
0062
0063
0064 namespace checked_deleters
0065 {
0066
0067 template<class T> struct checked_deleter
0068 {
0069 typedef void result_type;
0070 typedef T * argument_type;
0071
0072 void operator()(T * x) const BOOST_NOEXCEPT
0073 {
0074
0075 boost::checked_delete(x);
0076 }
0077 };
0078
0079 template<class T> struct checked_array_deleter
0080 {
0081 typedef void result_type;
0082 typedef T * argument_type;
0083
0084 void operator()(T * x) const BOOST_NOEXCEPT
0085 {
0086 boost::checked_array_delete(x);
0087 }
0088 };
0089
0090 }
0091
0092 using checked_deleters::checked_deleter;
0093 using checked_deleters::checked_array_deleter;
0094
0095 }
0096
0097 #endif