Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:29

0001 #ifndef BOOST_CORE_CHECKED_DELETE_HPP
0002 #define BOOST_CORE_CHECKED_DELETE_HPP
0003 
0004 // MS compatible compilers support #pragma once
0005 
0006 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
0007 # pragma once
0008 #endif
0009 
0010 #include <boost/config.hpp>
0011 
0012 //
0013 //  boost/checked_delete.hpp
0014 //
0015 //  Copyright (c) 2002, 2003 Peter Dimov
0016 //  Copyright (c) 2003 Daniel Frey
0017 //  Copyright (c) 2003 Howard Hinnant
0018 //
0019 //  Distributed under the Boost Software License, Version 1.0. (See
0020 //  accompanying file LICENSE_1_0.txt or copy at
0021 //  http://www.boost.org/LICENSE_1_0.txt)
0022 //
0023 //  See http://www.boost.org/libs/core/doc/html/core/checked_delete.html for documentation.
0024 //
0025 
0026 namespace boost
0027 {
0028 
0029 // verify that types are complete for increased safety
0030 
0031 template<class T> inline void checked_delete(T * x) BOOST_NOEXCEPT
0032 {
0033 #if defined(__cpp_static_assert) && __cpp_static_assert >= 200410L
0034 
0035     static_assert( sizeof(T) != 0, "Type must be complete" );
0036 
0037 #else
0038 
0039     typedef char type_must_be_complete[ sizeof(T) ];
0040     (void) sizeof(type_must_be_complete);
0041 
0042 #endif
0043 
0044     delete x;
0045 }
0046 
0047 template<class T> inline void checked_array_delete(T * x) BOOST_NOEXCEPT
0048 {
0049 #if defined(__cpp_static_assert) && __cpp_static_assert >= 200410L
0050 
0051     static_assert( sizeof(T) != 0, "Type must be complete" );
0052 
0053 #else
0054 
0055     typedef char type_must_be_complete[ sizeof(T) ];
0056     (void) sizeof(type_must_be_complete);
0057 
0058 #endif
0059 
0060     delete [] x;
0061 }
0062 
0063 template<class T> struct checked_deleter
0064 {
0065     typedef void result_type;
0066     typedef T * argument_type;
0067 
0068     void operator()(T * x) const BOOST_NOEXCEPT
0069     {
0070         // boost:: disables ADL
0071         boost::checked_delete(x);
0072     }
0073 };
0074 
0075 template<class T> struct checked_array_deleter
0076 {
0077     typedef void result_type;
0078     typedef T * argument_type;
0079 
0080     void operator()(T * x) const BOOST_NOEXCEPT
0081     {
0082         boost::checked_array_delete(x);
0083     }
0084 };
0085 
0086 } // namespace boost
0087 
0088 #endif  // #ifndef BOOST_CORE_CHECKED_DELETE_HPP