Go to the documentation of this file.00001 #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED
00002 #define BOOST_CHECKED_DELETE_HPP_INCLUDED
00003
00004
00005
00006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
00007 # pragma once
00008 #endif
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 namespace boost
00025 {
00026
00027
00028
00029 template<class T> inline void checked_delete(T * x)
00030 {
00031
00032 typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
00033 (void) sizeof(type_must_be_complete);
00034 delete x;
00035 }
00036
00037 template<class T> inline void checked_array_delete(T * x)
00038 {
00039 typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
00040 (void) sizeof(type_must_be_complete);
00041 delete [] x;
00042 }
00043
00044 template<class T> struct checked_deleter
00045 {
00046 typedef void result_type;
00047 typedef T * argument_type;
00048
00049 void operator()(T * x) const
00050 {
00051
00052 boost::checked_delete(x);
00053 }
00054 };
00055
00056 template<class T> struct checked_array_deleter
00057 {
00058 typedef void result_type;
00059 typedef T * argument_type;
00060
00061 void operator()(T * x) const
00062 {
00063 boost::checked_array_delete(x);
00064 }
00065 };
00066
00067 }
00068
00069 #endif // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED