comparison DEPENDENCIES/generic/include/boost/checked_delete.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
1 #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED 1 /*
2 #define BOOST_CHECKED_DELETE_HPP_INCLUDED 2 * Copyright (c) 2014 Glen Fernandes
3 *
4 * Distributed under the Boost Software License, Version 1.0. (See
5 * accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt)
7 */
3 8
4 // MS compatible compilers support #pragma once 9 #ifndef BOOST_CHECKED_DELETE_HPP
10 #define BOOST_CHECKED_DELETE_HPP
5 11
6 #if defined(_MSC_VER) && (_MSC_VER >= 1020) 12 // The header file at this path is deprecated;
7 # pragma once 13 // use boost/core/checked_delete.hpp instead.
14
15 #include <boost/core/checked_delete.hpp>
16
8 #endif 17 #endif
9
10 //
11 // boost/checked_delete.hpp
12 //
13 // Copyright (c) 2002, 2003 Peter Dimov
14 // Copyright (c) 2003 Daniel Frey
15 // Copyright (c) 2003 Howard Hinnant
16 //
17 // Distributed under the Boost Software License, Version 1.0. (See
18 // accompanying file LICENSE_1_0.txt or copy at
19 // http://www.boost.org/LICENSE_1_0.txt)
20 //
21 // See http://www.boost.org/libs/utility/checked_delete.html for documentation.
22 //
23
24 namespace boost
25 {
26
27 // verify that types are complete for increased safety
28
29 template<class T> inline void checked_delete(T * x)
30 {
31 // intentionally complex - simplification causes regressions
32 typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
33 (void) sizeof(type_must_be_complete);
34 delete x;
35 }
36
37 template<class T> inline void checked_array_delete(T * x)
38 {
39 typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
40 (void) sizeof(type_must_be_complete);
41 delete [] x;
42 }
43
44 template<class T> struct checked_deleter
45 {
46 typedef void result_type;
47 typedef T * argument_type;
48
49 void operator()(T * x) const
50 {
51 // boost:: disables ADL
52 boost::checked_delete(x);
53 }
54 };
55
56 template<class T> struct checked_array_deleter
57 {
58 typedef void result_type;
59 typedef T * argument_type;
60
61 void operator()(T * x) const
62 {
63 boost::checked_array_delete(x);
64 }
65 };
66
67 } // namespace boost
68
69 #endif // #ifndef BOOST_CHECKED_DELETE_HPP_INCLUDED