CppCMS

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

checked_delete.h
1 #ifndef BOOSTER_CHECKED_DELETE_H
2 #define BOOSTER_CHECKED_DELETE_H
3
4 //
5 // boost/checked_delete.hpp
6 //
7 // Copyright (c) 2002, 2003 Peter Dimov
8 // Copyright (c) 2003 Daniel Frey
9 // Copyright (c) 2003 Howard Hinnant
10 //
11 // Distributed under the Boost Software License, Version 1.0. (See
12 // accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
14 //
15 // See http://www.boost.org/libs/utility/checked_delete.html for documentation.
16 //
17
18 namespace booster
19 {
20
22
23 // verify that types are complete for increased safety
24
25 template<class T> inline void checked_delete(T * x)
26 {
27 // intentionally complex - simplification causes regressions
28 typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
29 (void) sizeof(type_must_be_complete);
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)? 1: -1 ];
36 (void) sizeof(type_must_be_complete);
37 delete [] x;
38 }
39
40 template<class T> struct checked_deleter
41 {
42 typedef void result_type;
43 typedef T * argument_type;
44
45 void operator()(T * x) const
46 {
47 // boost:: disables ADL
48 booster::checked_delete(x);
49 }
50 };
51
52 template<class T> struct checked_array_deleter
53 {
54 typedef void result_type;
55 typedef T * argument_type;
56
57 void operator()(T * x) const
58 {
59 booster::checked_array_delete(x);
60 }
61 };
63 } // namespace boost
64
65 #endif // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED
booster
Booster library namespace. The library that implements Boost Like API in ABI backward compatible way...
Definition: application.h:23