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