1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
2 | <meta name="generator" content="HTML Tidy, see www.w3.org"> |
---|
3 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
4 | <link rel="stylesheet" type="text/css" href="../boost.css"> |
---|
5 | |
---|
6 | <title>Boost.Python - <boost/python/pointee.hpp></title> |
---|
7 | |
---|
8 | <table border="0" cellpadding="7" cellspacing="0" width="100%" summary= |
---|
9 | "header"> |
---|
10 | <tr> |
---|
11 | <td valign="top" width="300"> |
---|
12 | <h3><a href="../../../../index.htm"><img height="86" width="277" alt= |
---|
13 | "C++ Boost" src="../../../../boost.png" border="0"></a></h3> |
---|
14 | |
---|
15 | <td valign="top"> |
---|
16 | <h1 align="center"><a href="../index.html">Boost.Python</a></h1> |
---|
17 | |
---|
18 | <h2 align="center">Header <boost/python/pointee.hpp></h2> |
---|
19 | </table> |
---|
20 | <hr> |
---|
21 | |
---|
22 | <h2>Contents</h2> |
---|
23 | |
---|
24 | <dl class="page-index"> |
---|
25 | <dt><a href="#introduction">Introduction</a> |
---|
26 | |
---|
27 | <dt><a href="#classes">Classes</a> |
---|
28 | |
---|
29 | <dd> |
---|
30 | <dl class="page-index"> |
---|
31 | <dt><a href="#pointee-spec">Class Template<code>pointee</code></a> |
---|
32 | |
---|
33 | <dd> |
---|
34 | <dl class="page-index"> |
---|
35 | <dt><a href="#pointee-spec-synopsis">Class Template |
---|
36 | <code>pointee</code> synopsis</a> |
---|
37 | </dl> |
---|
38 | </dl> |
---|
39 | |
---|
40 | <dt><a href="#examples">Example</a> |
---|
41 | </dl> |
---|
42 | <hr> |
---|
43 | |
---|
44 | <h2><a name="introduction"></a>Introduction</h2> |
---|
45 | |
---|
46 | <p><code><boost/python/pointee.hpp></code> introduces a |
---|
47 | traits <a |
---|
48 | href="../../../mpl/doc/refmanual/metafunction.html">metafunction</a> |
---|
49 | template <code>pointee<T></code> that can be used to extract the "pointed-to" type from the type of a pointer or smart pointer. |
---|
50 | |
---|
51 | <h2><a name="classes"></a>Classes</h2> |
---|
52 | |
---|
53 | <h3><a name="pointee-spec"></a>Class Template <code>pointee<class T></code></h3> |
---|
54 | |
---|
55 | <p><code>pointee<T></code> is used by the <code><a |
---|
56 | href="class.html#class_-spec">class_</a><...></code> |
---|
57 | template to deduce the type being held when a pointer or smart |
---|
58 | pointer type is used as its <code>HeldType</code> argument. |
---|
59 | |
---|
60 | <h4><a name="pointee-spec-synopsis"></a>Class Template |
---|
61 | <code>pointee</code> synopsis</h4> |
---|
62 | <pre> |
---|
63 | namespace boost { namespace python |
---|
64 | { |
---|
65 | template <class T> struct pointee |
---|
66 | { |
---|
67 | typedef T::element_type type; |
---|
68 | }; |
---|
69 | |
---|
70 | // specialization for pointers |
---|
71 | template <T> struct pointee<T*> |
---|
72 | { |
---|
73 | typedef T type; |
---|
74 | }; |
---|
75 | } |
---|
76 | </pre> |
---|
77 | |
---|
78 | |
---|
79 | <h2><a name="examples"></a>Example</h2> |
---|
80 | |
---|
81 | Given a 3rd-party smart pointer type |
---|
82 | <code>smart_pointer<T></code>, one might partially specialize |
---|
83 | <code>pointee<smart_pointer<T> ></code> so that it can be |
---|
84 | used as the <code>HeldType</code> for a class wrapper: |
---|
85 | |
---|
86 | <pre> |
---|
87 | #include <boost/python/pointee.hpp> |
---|
88 | #include <boost/python/class.hpp> |
---|
89 | #include <third_party_lib.hpp> |
---|
90 | |
---|
91 | namespace boost { namespace python |
---|
92 | { |
---|
93 | template <class T> struct pointee<smart_pointer<T> > |
---|
94 | { |
---|
95 | typedef T type; |
---|
96 | }; |
---|
97 | }} |
---|
98 | |
---|
99 | BOOST_PYTHON_MODULE(pointee_demo) |
---|
100 | { |
---|
101 | class_<third_party_class, smart_pointer<third_party_class> >("third_party_class") |
---|
102 | .def(...) |
---|
103 | ... |
---|
104 | ; |
---|
105 | } |
---|
106 | </pre> |
---|
107 | |
---|
108 | <p>Revised |
---|
109 | <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan --> |
---|
110 | 13 November, 2002 |
---|
111 | <!--webbot bot="Timestamp" endspan i-checksum="39359" --> |
---|
112 | |
---|
113 | |
---|
114 | <p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave |
---|
115 | Abrahams</a> 2002. </i> Distributed |
---|
116 | under the Boost Software License, Version 1.0. (See accompanying file |
---|
117 | LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)</p> |
---|
118 | |
---|
119 | |
---|