Chris@102: #ifndef BOOST_CORE_CHECKED_DELETE_HPP Chris@102: #define BOOST_CORE_CHECKED_DELETE_HPP Chris@102: Chris@102: // MS compatible compilers support #pragma once Chris@102: Chris@102: #if defined(_MSC_VER) && (_MSC_VER >= 1020) Chris@102: # pragma once Chris@102: #endif Chris@102: Chris@102: // Chris@102: // boost/checked_delete.hpp Chris@102: // Chris@102: // Copyright (c) 2002, 2003 Peter Dimov Chris@102: // Copyright (c) 2003 Daniel Frey Chris@102: // Copyright (c) 2003 Howard Hinnant Chris@102: // Chris@102: // Distributed under the Boost Software License, Version 1.0. (See Chris@102: // accompanying file LICENSE_1_0.txt or copy at Chris@102: // http://www.boost.org/LICENSE_1_0.txt) Chris@102: // Chris@102: // See http://www.boost.org/libs/core/doc/html/core/checked_delete.html for documentation. Chris@102: // Chris@102: Chris@102: namespace boost Chris@102: { Chris@102: Chris@102: // verify that types are complete for increased safety Chris@102: Chris@102: template inline void checked_delete(T * x) Chris@102: { Chris@102: // intentionally complex - simplification causes regressions Chris@102: typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; Chris@102: (void) sizeof(type_must_be_complete); Chris@102: delete x; Chris@102: } Chris@102: Chris@102: template inline void checked_array_delete(T * x) Chris@102: { Chris@102: typedef char type_must_be_complete[ sizeof(T)? 1: -1 ]; Chris@102: (void) sizeof(type_must_be_complete); Chris@102: delete [] x; Chris@102: } Chris@102: Chris@102: template struct checked_deleter Chris@102: { Chris@102: typedef void result_type; Chris@102: typedef T * argument_type; Chris@102: Chris@102: void operator()(T * x) const Chris@102: { Chris@102: // boost:: disables ADL Chris@102: boost::checked_delete(x); Chris@102: } Chris@102: }; Chris@102: Chris@102: template struct checked_array_deleter Chris@102: { Chris@102: typedef void result_type; Chris@102: typedef T * argument_type; Chris@102: Chris@102: void operator()(T * x) const Chris@102: { Chris@102: boost::checked_array_delete(x); Chris@102: } Chris@102: }; Chris@102: Chris@102: } // namespace boost Chris@102: Chris@102: #endif // #ifndef BOOST_CORE_CHECKED_DELETE_HPP