1 | #ifndef PTR_DWA20020601_HPP |
2 | # define PTR_DWA20020601_HPP |
3 | |
4 | # include <boost/python/detail/prefix.hpp> |
5 | // Copyright David Abrahams 2002. |
6 | // Distributed under the Boost Software License, Version 1.0. (See |
7 | // accompanying file LICENSE_1_0.txt or copy at |
8 | // http://www.boost.org/LICENSE_1_0.txt) |
9 | // |
10 | // Based on boost/ref.hpp, thus: |
11 | // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) |
12 | // Copyright (C) 2001 Peter Dimov |
13 | |
14 | # pragma once |
15 | |
16 | # include <boost/config.hpp> |
17 | # include <boost/mpl/bool.hpp> |
18 | |
19 | namespace boost { namespace python { |
20 | |
21 | template<class Ptr> class pointer_wrapper |
22 | { |
23 | public: |
24 | typedef Ptr type; |
25 | |
26 | explicit pointer_wrapper(Ptr x): p_(x) {} |
27 | operator Ptr() const { return p_; } |
28 | Ptr get() const { return p_; } |
29 | private: |
30 | Ptr p_; |
31 | }; |
32 | |
33 | template<class T> |
34 | inline pointer_wrapper<T> ptr(T t) |
35 | { |
36 | return pointer_wrapper<T>(t); |
37 | } |
38 | |
39 | template<typename T> |
40 | class is_pointer_wrapper |
41 | : public mpl::false_ |
42 | { |
43 | }; |
44 | |
45 | template<typename T> |
46 | class is_pointer_wrapper<pointer_wrapper<T> > |
47 | : public mpl::true_ |
48 | { |
49 | }; |
50 | |
51 | template<typename T> |
52 | class unwrap_pointer |
53 | { |
54 | public: |
55 | typedef T type; |
56 | }; |
57 | |
58 | template<typename T> |
59 | class unwrap_pointer<pointer_wrapper<T> > |
60 | { |
61 | public: |
62 | typedef T type; |
63 | }; |
64 | |
65 | }} // namespace boost::python |
66 | |
67 | #endif // #ifndef PTR_DWA20020601_HPP |
68 | |