Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/doc/v2/pointee.html @ 29

Last change on this file since 29 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 3.6 KB
Line 
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 - &lt;boost/python/pointee.hpp&gt;</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 &lt;boost/python/pointee.hpp&gt;</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>&lt;boost/python/pointee.hpp&gt;</code> introduces a
47    traits <a
48    href="../../../mpl/doc/refmanual/metafunction.html">metafunction</a>
49    template <code>pointee&lt;T&gt;</code> that can be used to extract the &quot;pointed-to&quot; 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&lt;class T&gt;</code></h3>
54
55    <p><code>pointee&lt;T&gt;</code> is used by the <code><a
56    href="class.html#class_-spec">class_</a>&lt;...&gt;</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>
63namespace boost { namespace python
64{
65   template &lt;class T&gt; struct pointee
66   {
67      typedef T::element_type type;
68   };
69
70   // specialization for pointers
71   template &lt;T&gt; struct pointee&lt;T*&gt;
72   {
73      typedef T type;
74   };
75}
76</pre>
77
78
79    <h2><a name="examples"></a>Example</h2>
80
81Given a 3rd-party smart pointer type
82<code>smart_pointer&lt;T&gt;</code>, one might partially specialize
83<code>pointee&lt;smart_pointer&ltT&gt; &gt;</code> so that it can be
84used as the <code>HeldType</code> for a class wrapper:
85
86<pre>
87#include &lt;boost/python/pointee.hpp&gt;
88#include &lt;boost/python/class.hpp&gt;
89#include &lt;third_party_lib.hpp&gt;
90
91namespace boost { namespace python
92{
93  template &lt;class T&gt; struct pointee&ltsmart_pointer&lt;T&gt; &gt;
94  {
95     typedef T type;
96  };
97}}
98
99BOOST_PYTHON_MODULE(pointee_demo)
100{
101   class_&lt;third_party_class, smart_pointer&lt;third_party_class&gt; &gt;(&quot;third_party_class&quot;)
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>&copy; 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
Note: See TracBrowser for help on using the repository browser.