]>
Commit | Line | Data |
---|---|---|
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 VOID_PTR_DWA200239_HPP | |
6 | # define VOID_PTR_DWA200239_HPP | |
7 | ||
8 | # include <boost/type_traits/remove_cv.hpp> | |
9 | ||
10 | namespace boost { namespace python { namespace detail { | |
11 | ||
12 | template <class U> | |
13 | inline U& void_ptr_to_reference(void const volatile* p, U&(*)()) | |
14 | { | |
15 | return *(U*)p; | |
16 | } | |
17 | ||
18 | template <class T> | |
19 | inline void write_void_ptr(void const volatile* storage, void* ptr, T*) | |
20 | { | |
21 | *(T**)storage = (T*)ptr; | |
22 | } | |
23 | ||
24 | // writes U(ptr) into the storage | |
25 | template <class U> | |
26 | inline void write_void_ptr_reference(void const volatile* storage, void* ptr, U&(*)()) | |
27 | { | |
28 | // stripping CV qualification suppresses warnings on older EDGs | |
29 | typedef typename remove_cv<U>::type u_stripped; | |
30 | write_void_ptr(storage, ptr, u_stripped(0)); | |
31 | } | |
32 | ||
33 | }}} // namespace boost::python::detail | |
34 | ||
35 | #endif // VOID_PTR_DWA200239_HPP |