src/sysc/packages/boost/checked_delete.hpp

Go to the documentation of this file.
00001 #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED
00002 #define BOOST_CHECKED_DELETE_HPP_INCLUDED
00003 
00004 #if _MSC_VER >= 1020
00005 #pragma once
00006 #endif
00007 
00008 //
00009 //  boost/checked_delete.hpp
00010 //
00011 //  Copyright (c) 1999, 2000, 2001, 2002 boost.org
00012 //
00013 //  Permission to copy, use, modify, sell and distribute this software
00014 //  is granted provided this copyright notice appears in all copies.
00015 //  This software is provided "as is" without express or implied
00016 //  warranty, and with no claim as to its suitability for any purpose.
00017 //
00018 
00019 namespace boost
00020 {
00021 
00022 // verify that types are complete for increased safety
00023 
00024 template< typename T > inline void checked_delete(T * x)
00025 {
00026     typedef char type_must_be_complete[sizeof(T)];
00027     delete x;
00028 }
00029 
00030 template< typename T > inline void checked_array_delete(T * x)
00031 {
00032     typedef char type_must_be_complete[sizeof(T)];
00033     delete [] x;
00034 }
00035 
00036 template<class T> struct checked_deleter
00037 {
00038     typedef void result_type;
00039     typedef T * argument_type;
00040 
00041     void operator()(T * x)
00042     {
00043         checked_delete(x);
00044     }
00045 };
00046 
00047 template<class T> struct checked_array_deleter
00048 {
00049     typedef void result_type;
00050     typedef T * argument_type;
00051 
00052     void operator()(T * x)
00053     {
00054         checked_array_delete(x);
00055     }
00056 };
00057 
00058 } // namespace boost
00059 
00060 #endif  // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED

Generated on Wed Apr 25 13:53:28 2007 for SystemC by  doxygen 1.5.1