| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <meta name="generator" content="HTML Tidy, see www.w3.org"> |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| <link rel="stylesheet" type="text/css" href="../boost.css"> |
| |
| <title>Boost.Python - <boost/python/pointee.hpp></title> |
| |
| <table border="0" cellpadding="7" cellspacing="0" width="100%" summary= |
| "header"> |
| <tr> |
| <td valign="top" width="300"> |
| <h3><a href="../../../../index.htm"><img height="86" width="277" alt= |
| "C++ Boost" src="../../../../boost.png" border="0"></a></h3> |
| |
| <td valign="top"> |
| <h1 align="center"><a href="../index.html">Boost.Python</a></h1> |
| |
| <h2 align="center">Header <boost/python/pointee.hpp></h2> |
| </table> |
| <hr> |
| |
| <h2>Contents</h2> |
| |
| <dl class="page-index"> |
| <dt><a href="#introduction">Introduction</a> |
| |
| <dt><a href="#classes">Classes</a> |
| |
| <dd> |
| <dl class="page-index"> |
| <dt><a href="#pointee-spec">Class Template<code>pointee</code></a> |
| |
| <dd> |
| <dl class="page-index"> |
| <dt><a href="#pointee-spec-synopsis">Class Template |
| <code>pointee</code> synopsis</a> |
| </dl> |
| </dl> |
| |
| <dt><a href="#examples">Example</a> |
| </dl> |
| <hr> |
| |
| <h2><a name="introduction"></a>Introduction</h2> |
| |
| <p><code><boost/python/pointee.hpp></code> introduces a |
| traits <a |
| href="../../../mpl/doc/refmanual/metafunction.html">metafunction</a> |
| template <code>pointee<T></code> that can be used to extract the "pointed-to" type from the type of a pointer or smart pointer. |
| |
| <h2><a name="classes"></a>Classes</h2> |
| |
| <h3><a name="pointee-spec"></a>Class Template <code>pointee<class T></code></h3> |
| |
| <p><code>pointee<T></code> is used by the <code><a |
| href="class.html#class_-spec">class_</a><...></code> |
| template to deduce the type being held when a pointer or smart |
| pointer type is used as its <code>HeldType</code> argument. |
| |
| <h4><a name="pointee-spec-synopsis"></a>Class Template |
| <code>pointee</code> synopsis</h4> |
| <pre> |
| namespace boost { namespace python |
| { |
| template <class T> struct pointee |
| { |
| typedef T::element_type type; |
| }; |
| |
| // specialization for pointers |
| template <T> struct pointee<T*> |
| { |
| typedef T type; |
| }; |
| } |
| </pre> |
| |
| |
| <h2><a name="examples"></a>Example</h2> |
| |
| Given a 3rd-party smart pointer type |
| <code>smart_pointer<T></code>, one might partially specialize |
| <code>pointee<smart_pointer<T> ></code> so that it can be |
| used as the <code>HeldType</code> for a class wrapper: |
| |
| <pre> |
| #include <boost/python/pointee.hpp> |
| #include <boost/python/class.hpp> |
| #include <third_party_lib.hpp> |
| |
| namespace boost { namespace python |
| { |
| template <class T> struct pointee<smart_pointer<T> > |
| { |
| typedef T type; |
| }; |
| }} |
| |
| BOOST_PYTHON_MODULE(pointee_demo) |
| { |
| class_<third_party_class, smart_pointer<third_party_class> >("third_party_class") |
| .def(...) |
| ... |
| ; |
| } |
| </pre> |
| |
| <p>Revised |
| <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan --> |
| 13 November, 2002 |
| <!--webbot bot="Timestamp" endspan i-checksum="39359" --> |
| |
| |
| <p><i>© Copyright <a href="http://www.boost.org/people/dave_abrahams.htm">Dave |
| Abrahams</a> 2002. </i> Distributed |
| under the Boost Software License, Version 1.0. (See accompanying file |
| LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)</p> |
| |
| |