1 #ifndef BOOST_CORE_CHECKED_DELETE_HPP
2 #define BOOST_CORE_CHECKED_DELETE_HPP
4 // MS compatible compilers support #pragma once
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
10 #include <boost/config.hpp>
13 // boost/checked_delete.hpp
15 // Copyright (c) 2002, 2003 Peter Dimov
16 // Copyright (c) 2003 Daniel Frey
17 // Copyright (c) 2003 Howard Hinnant
19 // Distributed under the Boost Software License, Version 1.0. (See
20 // accompanying file LICENSE_1_0.txt or copy at
21 // http://www.boost.org/LICENSE_1_0.txt)
23 // See http://www.boost.org/libs/core/doc/html/core/checked_delete.html for documentation.
29 // verify that types are complete for increased safety
31 template<class T> inline void checked_delete(T * x) BOOST_NOEXCEPT
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) BOOST_NOEXCEPT
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 BOOST_NOEXCEPT
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 BOOST_NOEXCEPT
65 boost::checked_array_delete(x);
71 #endif // #ifndef BOOST_CORE_CHECKED_DELETE_HPP