]> git.lyx.org Git - lyx.git/blob - boost/boost/checked_delete.hpp
complie fix
[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 //
13 //  Permission to copy, use, modify, sell and distribute this software
14 //  is granted provided this copyright notice appears in all copies.
15 //  This software is provided "as is" without express or implied
16 //  warranty, and with no claim as to its suitability for any purpose.
17 //
18
19 namespace boost
20 {
21
22 // verify that types are complete for increased safety
23
24 template< typename T > inline void checked_delete(T * x)
25 {
26     typedef char type_must_be_complete[sizeof(T)];
27     delete x;
28 }
29
30 template< typename T > inline void checked_array_delete(T * x)
31 {
32     typedef char type_must_be_complete[sizeof(T)];
33     delete [] x;
34 }
35
36 template<class T> struct checked_deleter
37 {
38     typedef void result_type;
39     typedef T * argument_type;
40
41     void operator()(T * x)
42     {
43         checked_delete(x);
44     }
45 };
46
47 template<class T> struct checked_array_deleter
48 {
49     typedef void result_type;
50     typedef T * argument_type;
51
52     void operator()(T * x)
53     {
54         checked_array_delete(x);
55     }
56 };
57
58 } // namespace boost
59
60 #endif  // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED