File indexing completed on 2025-01-18 09:30:29
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 template<class T> struct checked_deleter
0064 {
0065 typedef void result_type;
0066 typedef T * argument_type;
0067
0068 void operator()(T * x) const BOOST_NOEXCEPT
0069 {
0070
0071 boost::checked_delete(x);
0072 }
0073 };
0074
0075 template<class T> struct checked_array_deleter
0076 {
0077 typedef void result_type;
0078 typedef T * argument_type;
0079
0080 void operator()(T * x) const BOOST_NOEXCEPT
0081 {
0082 boost::checked_array_delete(x);
0083 }
0084 };
0085
0086 }
0087
0088 #endif