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 // MS compatible compilers support #pragma once
00005 
00006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
00007 # pragma once
00008 #endif
00009 
00010 //
00011 //  boost/checked_delete.hpp
00012 //
00013 //  Copyright (c) 2002, 2003 Peter Dimov
00014 //  Copyright (c) 2003 Daniel Frey
00015 //  Copyright (c) 2003 Howard Hinnant
00016 //
00017 //  Distributed under the Boost Software License, Version 1.0. (See
00018 //  accompanying file LICENSE_1_0.txt or copy at
00019 //  http://www.boost.org/LICENSE_1_0.txt)
00020 //
00021 //  See http://www.boost.org/libs/utility/checked_delete.html for documentation.
00022 //
00023 
00024 namespace boost
00025 {
00026 
00027 // verify that types are complete for increased safety
00028 
00029 template<class T> inline void checked_delete(T * x)
00030 {
00031     // intentionally complex - simplification causes regressions
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         // boost:: disables ADL
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 } // namespace boost
00068 
00069 #endif  // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED


appl
Author(s): petercai
autogenerated on Tue Jan 7 2014 11:02:28