1 #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED
2 #define BOOST_CHECKED_DELETE_HPP_INCLUDED
4 // MS compatible compilers support #pragma once
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
11 // boost/checked_delete.hpp
13 // Copyright (c) 1999, 2000, 2001, 2002 boost.org
14 // Copyright (c) 2002, 2003 Peter Dimov
15 // Copyright (c) 2003 Daniel Frey
16 // Copyright (c) 2003 Howard Hinnant
18 // Permission to copy, use, modify, sell and distribute this software
19 // is granted provided this copyright notice appears in all copies.
20 // This software is provided "as is" without express or implied
21 // warranty, and with no claim as to its suitability for any purpose.
23 // See http://www.boost.org/libs/utility/checked_delete.html for documentation.
29 // verify that types are complete for increased safety
31 template<class T> inline void checked_delete(T * x)
33 // intentionally complex - simplification causes regressions
34 typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
35 (void) sizeof(type_must_be_complete);
39 template<class T> inline void checked_array_delete(T * x)
41 typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
42 (void) sizeof(type_must_be_complete);
46 template<class T> struct checked_deleter
48 typedef void result_type;
49 typedef T * argument_type;
51 void operator()(T * x) const
53 // boost:: disables ADL
54 boost::checked_delete(x);
58 template<class T> struct checked_array_deleter
60 typedef void result_type;
61 typedef T * argument_type;
63 void operator()(T * x) const
65 boost::checked_array_delete(x);
71 #endif // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED