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