]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/checked_delete.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
e8f479f05b6ccc36340a4d78e1a8742c60f4fd0b
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / checked_delete.hpp
1 #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED\r
2 #define BOOST_CHECKED_DELETE_HPP_INCLUDED\r
3 \r
4 // MS compatible compilers support #pragma once\r
5 \r
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020)\r
7 # pragma once\r
8 #endif\r
9 \r
10 //\r
11 //  boost/checked_delete.hpp\r
12 //\r
13 //  Copyright (c) 2002, 2003 Peter Dimov\r
14 //  Copyright (c) 2003 Daniel Frey\r
15 //  Copyright (c) 2003 Howard Hinnant\r
16 //\r
17 //  Distributed under the Boost Software License, Version 1.0. (See\r
18 //  accompanying file LICENSE_1_0.txt or copy at\r
19 //  http://www.boost.org/LICENSE_1_0.txt)\r
20 //\r
21 //  See http://www.boost.org/libs/utility/checked_delete.html for documentation.\r
22 //\r
23 \r
24 namespace boost\r
25 {\r
26 \r
27 // verify that types are complete for increased safety\r
28 \r
29 template<class T> inline void checked_delete(T * x)\r
30 {\r
31     // intentionally complex - simplification causes regressions\r
32     typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];\r
33     (void) sizeof(type_must_be_complete);\r
34     delete x;\r
35 }\r
36 \r
37 template<class T> inline void checked_array_delete(T * x)\r
38 {\r
39     typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];\r
40     (void) sizeof(type_must_be_complete);\r
41     delete [] x;\r
42 }\r
43 \r
44 template<class T> struct checked_deleter\r
45 {\r
46     typedef void result_type;\r
47     typedef T * argument_type;\r
48 \r
49     void operator()(T * x) const\r
50     {\r
51         // boost:: disables ADL\r
52         boost::checked_delete(x);\r
53     }\r
54 };\r
55 \r
56 template<class T> struct checked_array_deleter\r
57 {\r
58     typedef void result_type;\r
59     typedef T * argument_type;\r
60 \r
61     void operator()(T * x) const\r
62     {\r
63         boost::checked_array_delete(x);\r
64     }\r
65 };\r
66 \r
67 } // namespace boost\r
68 \r
69 #endif  // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED\r