mirror of
https://github.com/boostorg/python.git
synced 2026-01-23 17:52:17 +00:00
90 lines
6.0 KiB
HTML
90 lines
6.0 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
|
|
<title>ptr.hpp</title>
|
|
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
|
|
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
<link rel="home" href="../index.html" title="Boost.Python Reference Manual">
|
|
<link rel="up" href="../function_invocation_and_creation.html" title="Chapter 4. Function Invocation and Creation">
|
|
<link rel="prev" href="boost_python_overloads_hpp/example.html" title="Example">
|
|
<link rel="next" href="ptr_hpp/functions.html" title="Functions">
|
|
</head>
|
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
<table cellpadding="2" width="100%"><tr>
|
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../images/boost.png"></td>
|
|
<td align="center"><a href="../../../index.html">Home</a></td>
|
|
<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
|
|
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
|
|
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
|
|
<td align="center"><a href="../../../more/index.htm">More</a></td>
|
|
</tr></table>
|
|
<hr>
|
|
<div class="spirit-nav">
|
|
<a accesskey="p" href="boost_python_overloads_hpp/example.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../function_invocation_and_creation.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="ptr_hpp/functions.html"><img src="../../images/next.png" alt="Next"></a>
|
|
</div>
|
|
<div class="section">
|
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
|
<a name="function_invocation_and_creation.ptr_hpp"></a><a class="link" href="ptr_hpp.html" title="ptr.hpp">ptr.hpp</a>
|
|
</h2></div></div></div>
|
|
<div class="toc"><dl class="toc">
|
|
<dt><span class="section"><a href="ptr_hpp.html#function_invocation_and_creation.ptr_hpp.introduction">Introduction</a></span></dt>
|
|
<dt><span class="section"><a href="ptr_hpp/functions.html">Functions</a></span></dt>
|
|
<dt><span class="section"><a href="ptr_hpp/class_template_pointer_wrapper.html">Class
|
|
template <code class="computeroutput"><span class="identifier">pointer_wrapper</span></code></a></span></dt>
|
|
<dt><span class="section"><a href="ptr_hpp/class_template_pointer_wrapper_t.html">Class
|
|
template <code class="computeroutput"><span class="identifier">pointer_wrapper</span></code>
|
|
types</a></span></dt>
|
|
<dt><span class="section"><a href="ptr_hpp/class_template_pointer_wrapper_c.html">Class
|
|
template <code class="computeroutput"><span class="identifier">pointer_wrapper</span></code>
|
|
constructors and destructor</a></span></dt>
|
|
<dt><span class="section"><a href="ptr_hpp/class_template_pointer_wrapper_o.html">Class
|
|
template <code class="computeroutput"><span class="identifier">pointer_wrapper</span></code>
|
|
observer functions</a></span></dt>
|
|
<dt><span class="section"><a href="ptr_hpp/metafunctions.html">Metafunctions</a></span></dt>
|
|
<dd><dl>
|
|
<dt><span class="section"><a href="ptr_hpp/metafunctions.html#function_invocation_and_creation.ptr_hpp.metafunctions.class_template_is_pointer_wrappe">Class
|
|
template <code class="computeroutput"><span class="identifier">is_pointer_wrapper</span></code></a></span></dt>
|
|
<dt><span class="section"><a href="ptr_hpp/metafunctions/class_template_unwrap_pointer.html">Class
|
|
template <code class="computeroutput"><span class="identifier">unwrap_pointer</span></code></a></span></dt>
|
|
</dl></dd>
|
|
<dt><span class="section"><a href="ptr_hpp/example.html">Example</a></span></dt>
|
|
</dl></div>
|
|
<div class="section">
|
|
<div class="titlepage"><div><div><h3 class="title">
|
|
<a name="function_invocation_and_creation.ptr_hpp.introduction"></a><a class="link" href="ptr_hpp.html#function_invocation_and_creation.ptr_hpp.introduction" title="Introduction">Introduction</a>
|
|
</h3></div></div></div>
|
|
<p>
|
|
<boost/python/ptr.hpp> defines the ptr() function template, which
|
|
allows users to specify how to convert C++ pointer values to python in
|
|
the context of implementing overridable virtual functions, invoking Python
|
|
callable objects, or explicitly converting C++ objects to Python. Normally,
|
|
when passing pointers to Python callbacks, the pointee is copied to ensure
|
|
that the Python object never holds a dangling reference. To specify that
|
|
the new Python object should merely contain a copy of a pointer p, the
|
|
user can pass ptr(p) instead of passing p directly. This interface is meant
|
|
to mirror the use of boost::ref(), which can be similarly used to prevent
|
|
copying of referents.
|
|
</p>
|
|
<p>
|
|
ptr(p) returns an instance of pointer_wrapper<>, which can be detected
|
|
using the is_pointer_wrapper<> metafunction; unwrap_pointer<>
|
|
is a metafunction which extracts the original pointer type from a pointer_wrapper<>.
|
|
These classes can be thought of as implementation details.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
|
<td align="left"></td>
|
|
<td align="right"><div class="copyright-footer">Copyright © 2002-2005, 2015 David Abrahams, Stefan Seefeld<p>
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>
|
|
</p>
|
|
</div></td>
|
|
</tr></table>
|
|
<hr>
|
|
<div class="spirit-nav">
|
|
<a accesskey="p" href="boost_python_overloads_hpp/example.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../function_invocation_and_creation.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="ptr_hpp/functions.html"><img src="../../images/next.png" alt="Next"></a>
|
|
</div>
|
|
</body>
|
|
</html>
|