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