]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/python/include/boost/python/detail/destroy.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / python / include / boost / python / detail / destroy.hpp
CommitLineData
7c673cae
FG
1// Copyright David Abrahams 2002.
2// Distributed under the Boost Software License, Version 1.0. (See
3// accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5#ifndef DESTROY_DWA2002221_HPP
6# define DESTROY_DWA2002221_HPP
7
8# include <boost/type_traits/is_array.hpp>
9# include <boost/detail/workaround.hpp>
10namespace boost { namespace python { namespace detail {
11
12template <bool array> struct value_destroyer;
13
14template <>
15struct value_destroyer<false>
16{
17 template <class T>
18 static void execute(T const volatile* p)
19 {
20 p->~T();
21 }
22};
23
24template <>
25struct value_destroyer<true>
26{
27 template <class A, class T>
28 static void execute(A*, T const volatile* const first)
29 {
30 for (T const volatile* p = first; p != first + sizeof(A)/sizeof(T); ++p)
31 {
32 value_destroyer<
33 boost::is_array<T>::value
34 >::execute(p);
35 }
36 }
37
38 template <class T>
39 static void execute(T const volatile* p)
40 {
41 execute(p, *p);
42 }
43};
44
45template <class T>
46inline void destroy_referent_impl(void* p, T& (*)())
47{
48 // note: cv-qualification needed for MSVC6
49 // must come *before* T for metrowerks
50 value_destroyer<
51 (boost::is_array<T>::value)
52 >::execute((const volatile T*)p);
53}
54
55template <class T>
56inline void destroy_referent(void* p, T(*)() = 0)
57{
58 destroy_referent_impl(p, (T(*)())0);
59}
60
61}}} // namespace boost::python::detail
62
63#endif // DESTROY_DWA2002221_HPP