]> git.lyx.org Git - lyx.git/blob - boost/boost/checked_delete.hpp
92a3d0a1c050fcb795dfdfbaa7e3f656334dda5e
[lyx.git] / boost / boost / checked_delete.hpp
1 #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED
2 #define BOOST_CHECKED_DELETE_HPP_INCLUDED
3
4 #if _MSC_VER >= 1020
5 #pragma once
6 #endif
7
8 //
9 //  boost/checked_delete.hpp
10 //
11 //  Copyright (c) 1999, 2000, 2001, 2002 boost.org
12 //  Copyright (c) 2002, 2003 Peter Dimov
13 //
14 //  Permission to copy, use, modify, sell and distribute this software
15 //  is granted provided this copyright notice appears in all copies.
16 //  This software is provided "as is" without express or implied
17 //  warranty, and with no claim as to its suitability for any purpose.
18 //
19 //  See http://www.boost.org/libs/utility/checked_delete.html for documentation.
20 //
21
22 namespace boost
23 {
24
25 // verify that types are complete for increased safety
26
27 template<class T> inline void checked_delete(T * x)
28 {
29     typedef char type_must_be_complete[sizeof(T)];
30     delete x;
31 }
32
33 template<class T> inline void checked_array_delete(T * x)
34 {
35     typedef char type_must_be_complete[sizeof(T)];
36     delete [] x;
37 }
38
39 template<class T> struct checked_deleter
40 {
41     typedef void result_type;
42     typedef T * argument_type;
43
44     void operator()(T * x) const
45     {
46         boost::checked_delete(x);
47     }
48 };
49
50 template<class T> struct checked_array_deleter
51 {
52     typedef void result_type;
53     typedef T * argument_type;
54
55     void operator()(T * x) const
56     {
57         boost::checked_array_delete(x);
58     }
59 };
60
61 } // namespace boost
62
63 #endif  // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED