• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Models of CallPolicies</title>
5<link rel="stylesheet" href="../../boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../index.html" title="Boost.Python Reference Manual">
8<link rel="up" href="../function_invocation_and_creation.html" title="Chapter 4. Function Invocation and Creation">
9<link rel="prev" href="function_documentation.html" title="Function documentation">
10<link rel="next" href="models_of_resultconverter.html" title="Models of ResultConverter">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../../images/boost.png"></td></tr></table>
14<hr>
15<div class="spirit-nav">
16<a accesskey="p" href="function_documentation.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="models_of_resultconverter.html"><img src="../../images/next.png" alt="Next"></a>
17</div>
18<div class="section">
19<div class="titlepage"><div><div><h2 class="title" style="clear: both">
20<a name="function_invocation_and_creation.models_of_callpolicies"></a><a class="link" href="models_of_callpolicies.html" title="Models of CallPolicies">Models
21      of CallPolicies</a>
22</h2></div></div></div>
23<div class="toc"><dl class="toc">
24<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici">boost/python/default_call_policies.hpp</a></span></dt>
25<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp">boost/python/return_arg.hpp</a></span></dt>
26<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref">boost/python/return_internal_reference.hpp</a></span></dt>
27<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_value_policy">boost/python/return_value_policy.hpp</a></span></dt>
28<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_">boost/python/with_custodian_and_ward.hpp</a></span></dt>
29</dl></div>
30<div class="section">
31<div class="titlepage"><div><div><h3 class="title">
32<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici" title="boost/python/default_call_policies.hpp">boost/python/default_call_policies.hpp</a>
33</h3></div></div></div>
34<div class="toc"><dl class="toc">
35<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.class_default_call_policies">Class
36          <code class="computeroutput"><span class="identifier">default_call_policies</span></code></a></span></dt>
37<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.class_default_call_policies_stat">Class
38          <code class="computeroutput"><span class="identifier">default_call_policies</span></code> static
39          functions</a></span></dt>
40<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.class_default_result_converter">Class
41          <code class="computeroutput"><span class="identifier">default_result_converter</span></code></a></span></dt>
42<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.class_default_result_converter_m">Class
43          <code class="computeroutput"><span class="identifier">default_result_converter</span></code>
44          metafunctions</a></span></dt>
45<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.example">Example</a></span></dt>
46</dl></div>
47<div class="section">
48<div class="titlepage"><div><div><h4 class="title">
49<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.class_default_call_policies"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.class_default_call_policies" title="Class default_call_policies">Class
50          <code class="computeroutput"><span class="identifier">default_call_policies</span></code></a>
51</h4></div></div></div>
52<p>
53            <code class="computeroutput"><span class="identifier">default_call_policies</span></code>
54            is a model of <a class="link" href="../concepts.html#concepts.callpolicies" title="CallPolicies"><code class="computeroutput"><span class="identifier">CallPolicies</span></code></a>
55            with no <code class="computeroutput"><span class="identifier">precall</span></code> or <code class="computeroutput"><span class="identifier">postcall</span></code> behavior and a <code class="computeroutput"><span class="identifier">result_converter</span></code> which handles by-value
56            returns. Wrapped C++ functions and member functions <code class="computeroutput"><span class="identifier">use</span>
57            <span class="identifier">default_call_policies</span></code> unless
58            otherwise specified. You may find it convenient to derive new models
59            of <a class="link" href="../concepts.html#concepts.callpolicies" title="CallPolicies"><code class="computeroutput"><span class="identifier">CallPolicies</span></code></a>
60            from <code class="computeroutput"><span class="identifier">default_call_policies</span></code>.
61          </p>
62<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">python</span>
63<span class="special">{</span>
64    <span class="keyword">struct</span> <span class="identifier">default_call_policies</span>
65    <span class="special">{</span>
66        <span class="keyword">static</span> <span class="keyword">bool</span> <span class="identifier">precall</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*);</span>
67        <span class="keyword">static</span> <span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">postcall</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*,</span> <span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">result</span><span class="special">);</span>
68        <span class="keyword">typedef</span> <span class="identifier">default_result_converter</span> <span class="identifier">result_converter</span><span class="special">;</span>
69        <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Sig</span><span class="special">&gt;</span> <span class="keyword">struct</span> <span class="identifier">extract_return_type</span> <span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">front</span><span class="special">&lt;</span><span class="identifier">Sig</span><span class="special">&gt;{};</span>
70    <span class="special">};</span>
71<span class="special">}}</span>
72</pre>
73</div>
74<div class="section">
75<div class="titlepage"><div><div><h4 class="title">
76<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.class_default_call_policies_stat"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.class_default_call_policies_stat" title="Class default_call_policies static functions">Class
77          <code class="computeroutput"><span class="identifier">default_call_policies</span></code> static
78          functions</a>
79</h4></div></div></div>
80<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">precall</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*);</span></pre>
81<div class="variablelist">
82<p class="title"><b></b></p>
83<dl class="variablelist">
84<dt><span class="term">Returns</span></dt>
85<dd><p>
86                  true
87                </p></dd>
88<dt><span class="term">Throws</span></dt>
89<dd><p>
90                  nothing
91                </p></dd>
92</dl>
93</div>
94<pre class="programlisting"><span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">postcall</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*,</span> <span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">result</span><span class="special">);</span></pre>
95<div class="variablelist">
96<p class="title"><b></b></p>
97<dl class="variablelist">
98<dt><span class="term">Returns</span></dt>
99<dd><p>
100                  result
101                </p></dd>
102<dt><span class="term">Throws</span></dt>
103<dd><p>
104                  nothing
105                </p></dd>
106</dl>
107</div>
108</div>
109<div class="section">
110<div class="titlepage"><div><div><h4 class="title">
111<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.class_default_result_converter"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.class_default_result_converter" title="Class default_result_converter">Class
112          <code class="computeroutput"><span class="identifier">default_result_converter</span></code></a>
113</h4></div></div></div>
114<p>
115            default_result_converter is a model of <a class="link" href="../concepts/resultconverter.html#concepts.resultconverter.resultconvertergenerator_concept" title="ResultConverterGenerator Concept Requirements"><code class="computeroutput"><span class="identifier">ResultConverterGenerator</span></code></a> which
116            can be used to wrap C++ functions returning non-pointer types, <code class="computeroutput"><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span></code>, and <code class="computeroutput"><span class="identifier">PyObject</span><span class="special">*</span></code>, by-value.
117          </p>
118<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">python</span>
119<span class="special">{</span>
120    <span class="keyword">struct</span> <span class="identifier">default_result_converter</span>
121    <span class="special">{</span>
122        <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">struct</span> <span class="identifier">apply</span><span class="special">;</span>
123    <span class="special">};</span>
124<span class="special">}}</span>
125</pre>
126</div>
127<div class="section">
128<div class="titlepage"><div><div><h4 class="title">
129<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.class_default_result_converter_m"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.class_default_result_converter_m" title="Class default_result_converter metafunctions">Class
130          <code class="computeroutput"><span class="identifier">default_result_converter</span></code>
131          metafunctions</a>
132</h4></div></div></div>
133<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">struct</span> <span class="identifier">apply</span></pre>
134<div class="variablelist">
135<p class="title"><b></b></p>
136<dl class="variablelist">
137<dt><span class="term">Requires</span></dt>
138<dd><p>
139                  T is not a reference type. If T is a pointer type, T is const char*
140                  or PyObject*.
141                </p></dd>
142<dt><span class="term">Returns</span></dt>
143<dd><p>
144                  typedef to_python_value&lt;T const&amp;&gt; type;
145                </p></dd>
146</dl>
147</div>
148</div>
149<div class="section">
150<div class="titlepage"><div><div><h4 class="title">
151<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.example"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_default_call_polici.example" title="Example">Example</a>
152</h4></div></div></div>
153<p>
154            This example comes from the Boost.Python implementation itself. Because
155            the return_value_policy class template does not implement precall or
156            postcall behavior, its default base class is default_call_policies:
157          </p>
158<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Handler</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Base</span> <span class="special">=</span> <span class="identifier">default_call_policies</span><span class="special">&gt;</span>
159<span class="keyword">struct</span> <span class="identifier">return_value_policy</span> <span class="special">:</span> <span class="identifier">Base</span>
160<span class="special">{</span>
161   <span class="keyword">typedef</span> <span class="identifier">Handler</span> <span class="identifier">result_converter</span><span class="special">;</span>
162<span class="special">};</span>
163</pre>
164</div>
165</div>
166<div class="section">
167<div class="titlepage"><div><div><h3 class="title">
168<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp" title="boost/python/return_arg.hpp">boost/python/return_arg.hpp</a>
169</h3></div></div></div>
170<div class="toc"><dl class="toc">
171<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.introduction">Introduction</a></span></dt>
172<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.class_return_arg">Class
173          <code class="computeroutput"><span class="identifier">return_arg</span></code></a></span></dt>
174<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.class_return_arg_static_function">Class
175          <code class="computeroutput"><span class="identifier">return_arg</span></code> static functions</a></span></dt>
176<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.class_template_return_self">Class
177          template <code class="computeroutput"><span class="identifier">return_self</span></code></a></span></dt>
178<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.example">Example</a></span></dt>
179</dl></div>
180<div class="section">
181<div class="titlepage"><div><div><h4 class="title">
182<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.introduction"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.introduction" title="Introduction">Introduction</a>
183</h4></div></div></div>
184<p>
185            <code class="computeroutput"><span class="identifier">return_arg</span></code> and <code class="computeroutput"><span class="identifier">return_self</span></code> instantiations are models
186            of <a class="link" href="../concepts.html#concepts.callpolicies" title="CallPolicies"><code class="computeroutput"><span class="identifier">CallPolicies</span></code></a>
187            which return the specified argument parameter (usually <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>)
188            of a wrapped (member) function.
189          </p>
190</div>
191<div class="section">
192<div class="titlepage"><div><div><h4 class="title">
193<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.class_return_arg"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.class_return_arg" title="Class return_arg">Class
194          <code class="computeroutput"><span class="identifier">return_arg</span></code></a>
195</h4></div></div></div>
196<div class="informaltable"><table class="table">
197<colgroup>
198<col>
199<col>
200<col>
201<col>
202</colgroup>
203<thead><tr>
204<th>
205                    <p>
206                      Parameter
207                    </p>
208                  </th>
209<th>
210                    <p>
211                      Requirements
212                    </p>
213                  </th>
214<th>
215                    <p>
216                      Description
217                    </p>
218                  </th>
219<th>
220                    <p>
221                      Default
222                    </p>
223                  </th>
224</tr></thead>
225<tbody>
226<tr>
227<td>
228                    <p>
229                      arg_pos
230                    </p>
231                  </td>
232<td>
233                    <p>
234                      A positive compile-time constant of type <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>.
235                    </p>
236                  </td>
237<td>
238                    <p>
239                      the position of the argument to be returned.
240                    </p>
241                  </td>
242<td>
243                    <p>
244                      1
245                    </p>
246                  </td>
247</tr>
248<tr>
249<td>
250                    <p>
251                      Base
252                    </p>
253                  </td>
254<td>
255                    <p>
256                      A model of <a class="link" href="../concepts.html#concepts.callpolicies" title="CallPolicies"><code class="computeroutput"><span class="identifier">CallPolicies</span></code></a>
257                    </p>
258                  </td>
259<td>
260                    <p>
261                      Used for policy composition. Any <code class="computeroutput"><span class="identifier">result_converter</span></code>
262                      it supplies will be overridden by <code class="computeroutput"><span class="identifier">return_arg</span></code>,
263                      but its <code class="computeroutput"><span class="identifier">precall</span></code>
264                      and <code class="computeroutput"><span class="identifier">postcall</span></code>
265                      policies are composed as described here <a class="link" href="../concepts.html#concepts.callpolicies" title="CallPolicies"><code class="computeroutput"><span class="identifier">CallPolicies</span></code></a>.
266                    </p>
267                  </td>
268<td>
269                    <p>
270                      default_call_policies
271                    </p>
272                  </td>
273</tr>
274</tbody>
275</table></div>
276<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">python</span>
277<span class="special">{</span>
278   <span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">size_t</span> <span class="identifier">arg_pos</span><span class="special">=</span><span class="number">1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Base</span> <span class="special">=</span> <span class="identifier">default_call_policies</span><span class="special">&gt;</span>
279   <span class="keyword">struct</span> <span class="identifier">return_arg</span> <span class="special">:</span> <span class="identifier">Base</span>
280   <span class="special">{</span>
281      <span class="keyword">static</span> <span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">postcall</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*,</span> <span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">result</span><span class="special">);</span>
282      <span class="keyword">struct</span> <span class="identifier">result_converter</span><span class="special">{</span> <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span> <span class="keyword">struct</span> <span class="identifier">apply</span><span class="special">;</span> <span class="special">};</span>
283      <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Sig</span><span class="special">&gt;</span> <span class="keyword">struct</span> <span class="identifier">extract_return_type</span> <span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">at_c</span><span class="special">&lt;</span><span class="identifier">Sig</span><span class="special">,</span> <span class="identifier">arg_pos</span><span class="special">&gt;{};</span>
284
285   <span class="special">};</span>
286<span class="special">}}</span>
287</pre>
288</div>
289<div class="section">
290<div class="titlepage"><div><div><h4 class="title">
291<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.class_return_arg_static_function"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.class_return_arg_static_function" title="Class return_arg static functions">Class
292          <code class="computeroutput"><span class="identifier">return_arg</span></code> static functions</a>
293</h4></div></div></div>
294<pre class="programlisting"><span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">postcall</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">args</span><span class="special">,</span> <span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">result</span><span class="special">);</span></pre>
295<div class="variablelist">
296<p class="title"><b></b></p>
297<dl class="variablelist">
298<dt><span class="term">Requires</span></dt>
299<dd><p>
300                  <code class="computeroutput"><span class="identifier">PyTuple_Check</span><span class="special">(</span><span class="identifier">args</span><span class="special">)</span>
301                  <span class="special">!=</span> <span class="number">0</span></code>
302                  and <code class="computeroutput"><span class="identifier">PyTuple_Size</span><span class="special">(</span><span class="identifier">args</span><span class="special">)</span> <span class="special">!=</span> <span class="number">0</span></code>
303                </p></dd>
304<dt><span class="term">Returns</span></dt>
305<dd><p>
306                  PyTuple_GetItem(args,arg_pos-1)
307                </p></dd>
308</dl>
309</div>
310</div>
311<div class="section">
312<div class="titlepage"><div><div><h4 class="title">
313<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.class_template_return_self"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.class_template_return_self" title="Class template return_self">Class
314          template <code class="computeroutput"><span class="identifier">return_self</span></code></a>
315</h4></div></div></div>
316<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">python</span>
317<span class="special">{</span>
318   <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Base</span> <span class="special">=</span> <span class="identifier">default_call_policies</span><span class="special">&gt;</span>
319   <span class="keyword">struct</span> <span class="identifier">return_self</span>
320     <span class="special">:</span> <span class="identifier">return_arg</span><span class="special">&lt;</span><span class="number">1</span><span class="special">,</span><span class="identifier">Base</span><span class="special">&gt;</span>
321   <span class="special">{};</span>
322<span class="special">}}</span>
323</pre>
324</div>
325<div class="section">
326<div class="titlepage"><div><div><h4 class="title">
327<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.example"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_arg_hpp.example" title="Example">Example</a>
328</h4></div></div></div>
329<p>
330            C++ module definition:
331          </p>
332<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">module</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
333<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="keyword">class</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
334<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">return_arg</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
335
336<span class="keyword">struct</span> <span class="identifier">Widget</span>
337<span class="special">{</span>
338   <span class="identifier">Widget</span><span class="special">()</span> <span class="special">:</span><span class="identifier">sensitive_</span><span class="special">(</span><span class="keyword">true</span><span class="special">){}</span>
339   <span class="keyword">bool</span> <span class="identifier">get_sensitive</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">sensitive_</span><span class="special">;</span> <span class="special">}</span>
340   <span class="keyword">void</span> <span class="identifier">set_sensitive</span><span class="special">(</span><span class="keyword">bool</span> <span class="identifier">s</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">this</span><span class="special">-&gt;</span><span class="identifier">sensitive_</span> <span class="special">=</span> <span class="identifier">s</span><span class="special">;</span> <span class="special">}</span>
341 <span class="keyword">private</span><span class="special">:</span>
342   <span class="keyword">bool</span> <span class="identifier">sensitive_</span><span class="special">;</span>
343<span class="special">};</span>
344
345<span class="keyword">struct</span> <span class="identifier">Label</span> <span class="special">:</span> <span class="identifier">Widget</span>
346<span class="special">{</span>
347   <span class="identifier">Label</span><span class="special">()</span> <span class="special">{}</span>
348
349   <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span>  <span class="identifier">get_label</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">label_</span><span class="special">;</span> <span class="special">}</span>
350   <span class="keyword">void</span> <span class="identifier">set_label</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&amp;</span><span class="identifier">l</span><span class="special">){</span> <span class="identifier">label_</span> <span class="special">=</span> <span class="identifier">l</span><span class="special">;</span> <span class="special">}</span>
351
352 <span class="keyword">private</span><span class="special">:</span>
353   <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">label_</span><span class="special">;</span>
354<span class="special">};</span>
355
356<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">;</span>
357<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">return_self_ext</span><span class="special">)</span>
358<span class="special">{</span>
359   <span class="identifier">class_</span><span class="special">&lt;</span><span class="identifier">widget</span><span class="special">&gt;(</span><span class="string">"Widget"</span><span class="special">)</span>
360      <span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"sensitive"</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">Widget</span><span class="special">::</span><span class="identifier">get_sensitive</span><span class="special">)</span>
361      <span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"sensitive"</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">Widget</span><span class="special">::</span><span class="identifier">set_sensitive</span><span class="special">,</span> <span class="identifier">return_self</span><span class="special">&lt;&gt;())</span>
362      <span class="special">;</span>
363
364   <span class="identifier">class_</span><span class="special">&lt;</span><span class="identifier">Label</span><span class="special">,</span> <span class="identifier">bases</span><span class="special">&lt;</span><span class="identifier">Widget</span><span class="special">&gt;</span> <span class="special">&gt;(</span><span class="string">"Label"</span><span class="special">)</span>
365      <span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"label"</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">Label</span><span class="special">::</span><span class="identifier">get_label</span><span class="special">)</span>
366      <span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"label"</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">Label</span><span class="special">::</span><span class="identifier">set_label</span><span class="special">,</span> <span class="identifier">return_self</span><span class="special">&lt;&gt;())</span>
367      <span class="special">;</span>
368<span class="special">}</span>
369</pre>
370<p>
371            Python code:
372          </p>
373<pre class="programlisting"><span class="special">&gt;&gt;&gt;</span> <span class="identifier">from</span> <span class="identifier">return_self_ext</span> <span class="identifier">import</span> <span class="special">*</span>
374<span class="special">&gt;&gt;&gt;</span> <span class="identifier">l1</span> <span class="special">=</span> <span class="identifier">Label</span><span class="special">().</span><span class="identifier">label</span><span class="special">(</span><span class="string">"foo"</span><span class="special">).</span><span class="identifier">sensitive</span><span class="special">(</span><span class="keyword">false</span><span class="special">)</span>
375<span class="special">&gt;&gt;&gt;</span> <span class="identifier">l2</span> <span class="special">=</span> <span class="identifier">Label</span><span class="special">().</span><span class="identifier">sensitive</span><span class="special">(</span><span class="keyword">false</span><span class="special">).</span><span class="identifier">label</span><span class="special">(</span><span class="string">"foo"</span><span class="special">)</span>
376</pre>
377</div>
378</div>
379<div class="section">
380<div class="titlepage"><div><div><h3 class="title">
381<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref" title="boost/python/return_internal_reference.hpp">boost/python/return_internal_reference.hpp</a>
382</h3></div></div></div>
383<div class="toc"><dl class="toc">
384<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref.introduction">Introduction</a></span></dt>
385<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref.class_template_return_internal_r">Class
386          template <code class="computeroutput"><span class="identifier">return_internal_reference</span></code></a></span></dt>
387<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref.class_return_internal_reference_">Class
388          <code class="computeroutput"><span class="identifier">return_internal_reference</span></code>
389          static functions</a></span></dt>
390<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref.example">Example</a></span></dt>
391</dl></div>
392<div class="section">
393<div class="titlepage"><div><div><h4 class="title">
394<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref.introduction"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref.introduction" title="Introduction">Introduction</a>
395</h4></div></div></div>
396<p>
397            <code class="computeroutput"><span class="identifier">return_internal_reference</span></code>
398            instantiations are models of <a class="link" href="../concepts.html#concepts.callpolicies" title="CallPolicies"><code class="computeroutput"><span class="identifier">CallPolicies</span></code></a> which allow pointers
399            and references to objects held internally by a free or member function
400            argument or from the target of a member function to be returned safely
401            without making a copy of the referent. The default for its first template
402            argument handles the common case where the containing object is the target
403            (<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>)
404            of a wrapped member function.
405          </p>
406</div>
407<div class="section">
408<div class="titlepage"><div><div><h4 class="title">
409<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref.class_template_return_internal_r"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref.class_template_return_internal_r" title="Class template return_internal_reference">Class
410          template <code class="computeroutput"><span class="identifier">return_internal_reference</span></code></a>
411</h4></div></div></div>
412<div class="informaltable"><table class="table">
413<colgroup>
414<col>
415<col>
416<col>
417<col>
418</colgroup>
419<thead><tr>
420<th>
421                    <p>
422                      Parameter
423                    </p>
424                  </th>
425<th>
426                    <p>
427                      Requirements
428                    </p>
429                  </th>
430<th>
431                    <p>
432                      Description
433                    </p>
434                  </th>
435<th>
436                    <p>
437                      Default
438                    </p>
439                  </th>
440</tr></thead>
441<tbody>
442<tr>
443<td>
444                    <p>
445                      owner_arg
446                    </p>
447                  </td>
448<td>
449                    <p>
450                      A positive compile-time constant of type <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>.
451                    </p>
452                  </td>
453<td>
454                    <p>
455                      The index of the parameter which contains the object to which
456                      the reference or pointer is being returned. If used to wrap
457                      a member function, parameter 1 is the target object (<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>).
458                      Note that if the target Python object type doesn't support
459                      weak references, a Python TypeError exception will be raised
460                      when the function being wrapped is called.
461                    </p>
462                  </td>
463<td>
464                  </td>
465</tr>
466<tr>
467<td>
468                    <p>
469                      Base
470                    </p>
471                  </td>
472<td>
473                    <p>
474                      A model of <a class="link" href="../concepts.html#concepts.callpolicies" title="CallPolicies"><code class="computeroutput"><span class="identifier">CallPolicies</span></code></a>
475                    </p>
476                  </td>
477<td>
478                    <p>
479                      Used for policy composition. Any <code class="computeroutput"><span class="identifier">result_converter</span></code>
480                      it supplies will be overridden by <code class="computeroutput"><span class="identifier">return_internal_reference</span></code>,
481                      but its <code class="computeroutput"><span class="identifier">precall</span></code>
482                      and <code class="computeroutput"><span class="identifier">postcall</span></code>
483                      policies are composed as described here <a class="link" href="../concepts.html#concepts.callpolicies" title="CallPolicies"><code class="computeroutput"><span class="identifier">CallPolicies</span></code></a>.
484                    </p>
485                  </td>
486<td>
487                    <p>
488                      default_call_policies
489                    </p>
490                  </td>
491</tr>
492</tbody>
493</table></div>
494<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">python</span>
495<span class="special">{</span>
496   <span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">owner_arg</span> <span class="special">=</span> <span class="number">1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Base</span> <span class="special">=</span> <span class="identifier">default_call_policies</span><span class="special">&gt;</span>
497   <span class="keyword">struct</span> <span class="identifier">return_internal_reference</span> <span class="special">:</span> <span class="identifier">Base</span>
498   <span class="special">{</span>
499      <span class="keyword">static</span> <span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">postcall</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*,</span> <span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">result</span><span class="special">);</span>
500      <span class="keyword">typedef</span> <span class="identifier">reference_existing_object</span> <span class="identifier">result_converter</span><span class="special">;</span>
501   <span class="special">};</span>
502<span class="special">}}</span>
503</pre>
504</div>
505<div class="section">
506<div class="titlepage"><div><div><h4 class="title">
507<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref.class_return_internal_reference_"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref.class_return_internal_reference_" title="Class return_internal_reference static functions">Class
508          <code class="computeroutput"><span class="identifier">return_internal_reference</span></code>
509          static functions</a>
510</h4></div></div></div>
511<pre class="programlisting"><span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">postcall</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">args</span><span class="special">,</span> <span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">result</span><span class="special">);</span></pre>
512<div class="variablelist">
513<p class="title"><b></b></p>
514<dl class="variablelist">
515<dt><span class="term">Requires</span></dt>
516<dd><p>
517                  <code class="computeroutput"><span class="identifier">PyTuple_Check</span><span class="special">(</span><span class="identifier">args</span><span class="special">)</span>
518                  <span class="special">!=</span> <span class="number">0</span></code>
519                </p></dd>
520<dt><span class="term">Returns</span></dt>
521<dd><p>
522                  <a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.class_with_custodian_and_ward_st" title="Class with_custodian_and_ward static functions"><code class="computeroutput"><span class="identifier">with_custodian_and_ward_postcall</span><span class="special">::</span><span class="identifier">postcall</span><span class="special">(</span><span class="identifier">args</span><span class="special">,</span> <span class="identifier">result</span><span class="special">)</span></code></a>
523                </p></dd>
524</dl>
525</div>
526</div>
527<div class="section">
528<div class="titlepage"><div><div><h4 class="title">
529<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref.example"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref.example" title="Example">Example</a>
530</h4></div></div></div>
531<p>
532            C++ module definition:
533          </p>
534<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">module</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
535<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="keyword">class</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
536<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">return_internal_reference</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
537
538<span class="keyword">class</span> <span class="identifier">Bar</span>
539<span class="special">{</span>
540 <span class="keyword">public</span><span class="special">:</span>
541   <span class="identifier">Bar</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">x</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">{}</span>
542   <span class="keyword">int</span> <span class="identifier">get_x</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">x</span><span class="special">;</span> <span class="special">}</span>
543   <span class="keyword">void</span> <span class="identifier">set_x</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">this</span><span class="special">-&gt;</span><span class="identifier">x</span> <span class="special">=</span> <span class="identifier">x</span><span class="special">;</span> <span class="special">}</span>
544 <span class="keyword">private</span><span class="special">:</span>
545   <span class="keyword">int</span> <span class="identifier">x</span><span class="special">;</span>
546<span class="special">};</span>
547
548<span class="keyword">class</span> <span class="identifier">Foo</span>
549<span class="special">{</span>
550 <span class="keyword">public</span><span class="special">:</span>
551   <span class="identifier">Foo</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">b</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span> <span class="special">{}</span>
552
553   <span class="comment">// Returns an internal reference</span>
554   <span class="identifier">Bar</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">get_bar</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">b</span><span class="special">;</span> <span class="special">}</span>
555
556 <span class="keyword">private</span><span class="special">:</span>
557   <span class="identifier">Bar</span> <span class="identifier">b</span><span class="special">;</span>
558<span class="special">};</span>
559
560<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">;</span>
561<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">internal_refs</span><span class="special">)</span>
562<span class="special">{</span>
563   <span class="identifier">class_</span><span class="special">&lt;</span><span class="identifier">Bar</span><span class="special">&gt;(</span><span class="string">"Bar"</span><span class="special">,</span> <span class="identifier">init</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;())</span>
564      <span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"get_x"</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">Bar</span><span class="special">::</span><span class="identifier">get_x</span><span class="special">)</span>
565      <span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"set_x"</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">Bar</span><span class="special">::</span><span class="identifier">set_x</span><span class="special">)</span>
566      <span class="special">;</span>
567
568   <span class="identifier">class_</span><span class="special">&lt;</span><span class="identifier">Foo</span><span class="special">&gt;(</span><span class="string">"Foo"</span><span class="special">,</span> <span class="identifier">init</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;())</span>
569      <span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"get_bar"</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">Foo</span><span class="special">::</span><span class="identifier">get_bar</span>
570          <span class="special">,</span> <span class="identifier">return_internal_reference</span><span class="special">&lt;&gt;())</span>
571      <span class="special">;</span>
572<span class="special">}</span>
573</pre>
574<p>
575            Python code:
576          </p>
577<pre class="programlisting"><span class="special">&gt;&gt;&gt;</span> <span class="identifier">from</span> <span class="identifier">internal_refs</span> <span class="identifier">import</span> <span class="special">*</span>
578<span class="special">&gt;&gt;&gt;</span> <span class="identifier">f</span> <span class="special">=</span> <span class="identifier">Foo</span><span class="special">(</span><span class="number">3</span><span class="special">)</span>
579<span class="special">&gt;&gt;&gt;</span> <span class="identifier">b1</span> <span class="special">=</span> <span class="identifier">f</span><span class="special">.</span><span class="identifier">get_bar</span><span class="special">()</span>
580<span class="special">&gt;&gt;&gt;</span> <span class="identifier">b2</span> <span class="special">=</span> <span class="identifier">f</span><span class="special">.</span><span class="identifier">get_bar</span><span class="special">()</span>
581<span class="special">&gt;&gt;&gt;</span> <span class="identifier">b1</span><span class="special">.</span><span class="identifier">get_x</span><span class="special">()</span>
582<span class="number">3</span>
583<span class="special">&gt;&gt;&gt;</span> <span class="identifier">b2</span><span class="special">.</span><span class="identifier">get_x</span><span class="special">()</span>
584<span class="number">3</span>
585<span class="special">&gt;&gt;&gt;</span> <span class="identifier">b1</span><span class="special">.</span><span class="identifier">set_x</span><span class="special">(</span><span class="number">42</span><span class="special">)</span>
586<span class="special">&gt;&gt;&gt;</span> <span class="identifier">b2</span><span class="special">.</span><span class="identifier">get_x</span><span class="special">()</span>
587<span class="number">42</span>
588</pre>
589</div>
590</div>
591<div class="section">
592<div class="titlepage"><div><div><h3 class="title">
593<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_value_policy"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_value_policy" title="boost/python/return_value_policy.hpp">boost/python/return_value_policy.hpp</a>
594</h3></div></div></div>
595<div class="toc"><dl class="toc">
596<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_value_policy.introduction">Introduction</a></span></dt>
597<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_value_policy.class_template_return_value_poli">Class
598          template <code class="computeroutput"><span class="identifier">return_value_policy</span></code></a></span></dt>
599<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_value_policy.example">Example</a></span></dt>
600</dl></div>
601<div class="section">
602<div class="titlepage"><div><div><h4 class="title">
603<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_value_policy.introduction"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_value_policy.introduction" title="Introduction">Introduction</a>
604</h4></div></div></div>
605<p>
606            return_value_policy instantiations are simply models of <a class="link" href="../concepts.html#concepts.callpolicies" title="CallPolicies"><code class="computeroutput"><span class="identifier">CallPolicies</span></code></a> which are composed
607            of a <a class="link" href="../concepts/resultconverter.html#concepts.resultconverter.resultconvertergenerator_concept" title="ResultConverterGenerator Concept Requirements"><code class="computeroutput"><span class="identifier">ResultConverterGenerator</span></code></a> and
608            optional <code class="computeroutput"><span class="identifier">Base</span></code> <a class="link" href="../concepts.html#concepts.callpolicies" title="CallPolicies"><code class="computeroutput"><span class="identifier">CallPolicies</span></code></a>.
609          </p>
610</div>
611<div class="section">
612<div class="titlepage"><div><div><h4 class="title">
613<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_value_policy.class_template_return_value_poli"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_value_policy.class_template_return_value_poli" title="Class template return_value_policy">Class
614          template <code class="computeroutput"><span class="identifier">return_value_policy</span></code></a>
615</h4></div></div></div>
616<div class="informaltable"><table class="table">
617<colgroup>
618<col>
619<col>
620<col>
621</colgroup>
622<thead><tr>
623<th>
624                    <p>
625                      Parameter
626                    </p>
627                  </th>
628<th>
629                    <p>
630                      Requirements
631                    </p>
632                  </th>
633<th>
634                    <p>
635                      Default
636                    </p>
637                  </th>
638</tr></thead>
639<tbody>
640<tr>
641<td>
642                    <p>
643                      ResultConverterGenerator
644                    </p>
645                  </td>
646<td>
647                    <p>
648                      A model of <a class="link" href="../concepts/resultconverter.html#concepts.resultconverter.resultconvertergenerator_concept" title="ResultConverterGenerator Concept Requirements"><code class="computeroutput"><span class="identifier">ResultConverterGenerator</span></code></a>
649                    </p>
650                  </td>
651<td>
652                  </td>
653</tr>
654<tr>
655<td>
656                    <p>
657                      Base
658                    </p>
659                  </td>
660<td>
661                    <p>
662                      A model of <a class="link" href="../concepts.html#concepts.callpolicies" title="CallPolicies"><code class="computeroutput"><span class="identifier">CallPolicies</span></code></a>
663                    </p>
664                  </td>
665<td>
666                    <p>
667                      default_call_policies
668                    </p>
669                  </td>
670</tr>
671</tbody>
672</table></div>
673<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">python</span>
674<span class="special">{</span>
675  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">ResultConverterGenerator</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Base</span> <span class="special">=</span> <span class="identifier">default_call_policies</span><span class="special">&gt;</span>
676  <span class="keyword">struct</span> <span class="identifier">return_value_policy</span> <span class="special">:</span> <span class="identifier">Base</span>
677  <span class="special">{</span>
678      <span class="keyword">typedef</span> <span class="identifier">ResultConverterGenerator</span> <span class="identifier">result_converter</span><span class="special">;</span>
679  <span class="special">};</span>
680<span class="special">}}</span>
681</pre>
682</div>
683<div class="section">
684<div class="titlepage"><div><div><h4 class="title">
685<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_return_value_policy.example"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_value_policy.example" title="Example">Example</a>
686</h4></div></div></div>
687<p>
688            C++ module definition:
689          </p>
690<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">module</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
691<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="keyword">class</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
692<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">copy_const_reference</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
693<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">return_value_policy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
694
695<span class="comment">// classes to wrap</span>
696<span class="keyword">struct</span> <span class="identifier">Bar</span> <span class="special">{</span> <span class="keyword">int</span> <span class="identifier">x</span><span class="special">;</span> <span class="special">}</span>
697
698<span class="keyword">struct</span> <span class="identifier">Foo</span> <span class="special">{</span>
699   <span class="identifier">Foo</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">)</span> <span class="special">:</span> <span class="special">{</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">x</span> <span class="special">=</span> <span class="identifier">x</span><span class="special">;</span> <span class="special">}</span>
700   <span class="identifier">Bar</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">get_bar</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">b</span><span class="special">;</span> <span class="special">}</span>
701 <span class="keyword">private</span><span class="special">:</span>
702   <span class="identifier">Bar</span> <span class="identifier">b</span><span class="special">;</span>
703<span class="special">};</span>
704
705<span class="comment">// Wrapper code</span>
706<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">;</span>
707<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">my_module</span><span class="special">)</span>
708<span class="special">{</span>
709   <span class="identifier">class_</span><span class="special">&lt;</span><span class="identifier">Bar</span><span class="special">&gt;(</span><span class="string">"Bar"</span><span class="special">);</span>
710
711   <span class="identifier">class_</span><span class="special">&lt;</span><span class="identifier">Foo</span><span class="special">&gt;(</span><span class="string">"Foo"</span><span class="special">,</span> <span class="identifier">init</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">&gt;())</span>
712      <span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"get_bar"</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">Foo</span><span class="special">::</span><span class="identifier">get_bar</span>
713          <span class="special">,</span> <span class="identifier">return_value_policy</span><span class="special">&lt;</span><span class="identifier">copy_const_reference</span><span class="special">&gt;())</span>
714      <span class="special">;</span>
715<span class="special">}</span>
716</pre>
717<p>
718            Python code:
719          </p>
720<pre class="programlisting"><span class="special">&gt;&gt;&gt;</span> <span class="identifier">from</span> <span class="identifier">my_module</span> <span class="identifier">import</span> <span class="special">*</span>
721<span class="special">&gt;&gt;&gt;</span> <span class="identifier">f</span> <span class="special">=</span> <span class="identifier">Foo</span><span class="special">(</span><span class="number">3</span><span class="special">)</span>         <span class="special">#</span> <span class="identifier">create</span> <span class="identifier">a</span> <span class="identifier">Foo</span> <span class="identifier">object</span>
722<span class="special">&gt;&gt;&gt;</span> <span class="identifier">b</span> <span class="special">=</span> <span class="identifier">f</span><span class="special">.</span><span class="identifier">get_bar</span><span class="special">()</span>    <span class="special">#</span> <span class="identifier">make</span> <span class="identifier">a</span> <span class="identifier">copy</span> <span class="identifier">of</span> <span class="identifier">the</span> <span class="identifier">internal</span> <span class="identifier">Bar</span> <span class="identifier">object</span>
723</pre>
724</div>
725</div>
726<div class="section">
727<div class="titlepage"><div><div><h3 class="title">
728<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_" title="boost/python/with_custodian_and_ward.hpp">boost/python/with_custodian_and_ward.hpp</a>
729</h3></div></div></div>
730<div class="toc"><dl class="toc">
731<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.introduction">Introduction</a></span></dt>
732<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.class_with_custodian_and_ward">Class
733          <code class="computeroutput"><span class="identifier">with_custodian_and_ward</span></code></a></span></dt>
734<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.class_with_custodian_and_ward_st">Class
735          <code class="computeroutput"><span class="identifier">with_custodian_and_ward</span></code>
736          static functions</a></span></dt>
737<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.class_with_custodian_and_ward_po">Class
738          <code class="computeroutput"><span class="identifier">with_custodian_and_ward_postcall</span></code></a></span></dt>
739<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.class_with_custodian_and_ward_p0">Class
740          <code class="computeroutput"><span class="identifier">with_custodian_and_ward_postcall</span></code>
741          static functions</a></span></dt>
742<dt><span class="section"><a href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.example">Example</a></span></dt>
743</dl></div>
744<div class="section">
745<div class="titlepage"><div><div><h4 class="title">
746<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.introduction"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.introduction" title="Introduction">Introduction</a>
747</h4></div></div></div>
748<p>
749            This header provides facilities for establishing a lifetime dependency
750            between two of a function's Python argument or result objects. The ward
751            object will not be destroyed until after the custodian as long as the
752            custodian object supports <a href="http://www.python.org/doc/current/lib/module-weakref.html" target="_top">weak
753            references</a> (Boost.Python extension classes all support weak references).
754            If the custodian object does not support weak references and is not
755            <code class="computeroutput"><span class="identifier">None</span></code>, an appropriate
756            exception will be thrown. The two class templates <code class="computeroutput"><span class="identifier">with_custodian_and_ward</span></code>
757            and <code class="computeroutput"><span class="identifier">with_custodian_and_ward_postcall</span></code>
758            differ in the point at which they take effect.
759          </p>
760<p>
761            In order to reduce the chance of inadvertently creating dangling pointers,
762            the default is to do lifetime binding before the underlying C++ object
763            is invoked. However, before invocation the result object is not available,
764            so <code class="computeroutput"><span class="identifier">with_custodian_and_ward_postcall</span></code>
765            is provided to bind lifetimes after invocation. Also, if a C++ exception
766            is thrown after <code class="computeroutput"><span class="identifier">with_custodian_and_ward</span><span class="special">&lt;&gt;::</span><span class="identifier">precall</span></code>
767            but before the underlying C++ object actually stores a pointer, the lifetime
768            of the custodian and ward objects will be artificially bound together,
769            so one might choose <code class="computeroutput"><span class="identifier">with_custodian_and_ward_postcall</span></code>
770            instead, depending on the semantics of the function being wrapped.
771          </p>
772<p>
773            Please note that this is not the appropriate tool to use when wrapping
774            functions which transfer ownership of a raw pointer across the function-call
775            boundary. Please see the FAQ if you want to do that.
776          </p>
777</div>
778<div class="section">
779<div class="titlepage"><div><div><h4 class="title">
780<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.class_with_custodian_and_ward"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.class_with_custodian_and_ward" title="Class with_custodian_and_ward">Class
781          <code class="computeroutput"><span class="identifier">with_custodian_and_ward</span></code></a>
782</h4></div></div></div>
783<div class="informaltable"><table class="table">
784<colgroup>
785<col>
786<col>
787<col>
788<col>
789</colgroup>
790<thead><tr>
791<th>
792                    <p>
793                      Parameter
794                    </p>
795                  </th>
796<th>
797                    <p>
798                      Requirements
799                    </p>
800                  </th>
801<th>
802                    <p>
803                      Description
804                    </p>
805                  </th>
806<th>
807                    <p>
808                      Default
809                    </p>
810                  </th>
811</tr></thead>
812<tbody>
813<tr>
814<td>
815                    <p>
816                      custodian
817                    </p>
818                  </td>
819<td>
820                    <p>
821                      A positive compile-time constant of <code class="computeroutput"><span class="identifier">type</span>
822                      <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>.
823                    </p>
824                  </td>
825<td>
826                    <p>
827                      The 1-based index of the parameter which is the dependency
828                      in the lifetime relationship to be established. If used to
829                      wrap a member function, parameter 1 is the target object (<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>).
830                      Note that if the target Python object type doesn't support
831                      weak references, a Python TypeError exception will be raised
832                      when the C++ object being wrapped is called.
833                    </p>
834                  </td>
835<td>
836                  </td>
837</tr>
838<tr>
839<td>
840                    <p>
841                      ward
842                    </p>
843                  </td>
844<td>
845                    <p>
846                      A positive compile-time constant of type <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>.
847                    </p>
848                  </td>
849<td>
850                    <p>
851                      The 1-based index of the parameter which is the dependent in
852                      the lifetime relationship to be established. If used to wrap
853                      a member function, parameter 1 is the target object (<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>).
854                    </p>
855                  </td>
856<td>
857                  </td>
858</tr>
859<tr>
860<td>
861                    <p>
862                      Base
863                    </p>
864                  </td>
865<td>
866                    <p>
867                      A model of <a class="link" href="../concepts.html#concepts.callpolicies" title="CallPolicies"><code class="computeroutput"><span class="identifier">CallPolicies</span></code></a>
868                    </p>
869                  </td>
870<td>
871                    <p>
872                      Used for policy <a class="link" href="../concepts.html#concepts.callpolicies.callpolicies_composition" title="CallPolicies Composition">composition</a>.
873                    </p>
874                  </td>
875<td>
876                    <p>
877                      default_call_policies
878                    </p>
879                  </td>
880</tr>
881</tbody>
882</table></div>
883<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">python</span>
884<span class="special">{</span>
885   <span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">custodian</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">ward</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Base</span> <span class="special">=</span> <span class="identifier">default_call_policies</span><span class="special">&gt;</span>
886   <span class="keyword">struct</span> <span class="identifier">with_custodian_and_ward</span> <span class="special">:</span> <span class="identifier">Base</span>
887   <span class="special">{</span>
888      <span class="keyword">static</span> <span class="keyword">bool</span> <span class="identifier">precall</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">args</span><span class="special">);</span>
889   <span class="special">};</span>
890<span class="special">}}</span></pre>
891</div>
892<div class="section">
893<div class="titlepage"><div><div><h4 class="title">
894<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.class_with_custodian_and_ward_st"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.class_with_custodian_and_ward_st" title="Class with_custodian_and_ward static functions">Class
895          <code class="computeroutput"><span class="identifier">with_custodian_and_ward</span></code>
896          static functions</a>
897</h4></div></div></div>
898<pre class="programlisting"><span class="keyword">bool</span> <span class="identifier">precall</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">args</span><span class="special">);</span></pre>
899<div class="variablelist">
900<p class="title"><b></b></p>
901<dl class="variablelist">
902<dt><span class="term">Requires</span></dt>
903<dd><p>
904                  <code class="computeroutput"><span class="identifier">PyTuple_Check</span><span class="special">(</span><span class="identifier">args</span><span class="special">)</span>
905                  <span class="special">!=</span> <span class="number">0</span></code>
906                </p></dd>
907<dt><span class="term">Effects</span></dt>
908<dd><p>
909                  Makes the lifetime of the argument indicated by ward dependent
910                  on the lifetime of the argument indicated by custodian.
911                </p></dd>
912<dt><span class="term">Returns</span></dt>
913<dd><p>
914                  false and PyErr_Occurred() != 0 upon failure, true otherwise.
915                </p></dd>
916</dl>
917</div>
918</div>
919<div class="section">
920<div class="titlepage"><div><div><h4 class="title">
921<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.class_with_custodian_and_ward_po"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.class_with_custodian_and_ward_po" title="Class with_custodian_and_ward_postcall">Class
922          <code class="computeroutput"><span class="identifier">with_custodian_and_ward_postcall</span></code></a>
923</h4></div></div></div>
924<div class="informaltable"><table class="table">
925<colgroup>
926<col>
927<col>
928<col>
929<col>
930</colgroup>
931<thead><tr>
932<th>
933                    <p>
934                      Parameter
935                    </p>
936                  </th>
937<th>
938                    <p>
939                      Requirements
940                    </p>
941                  </th>
942<th>
943                    <p>
944                      Description
945                    </p>
946                  </th>
947<th>
948                    <p>
949                      Default
950                    </p>
951                  </th>
952</tr></thead>
953<tbody>
954<tr>
955<td>
956                    <p>
957                      custodian
958                    </p>
959                  </td>
960<td>
961                    <p>
962                      A positive compile-time constant of type <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>.
963                    </p>
964                  </td>
965<td>
966                    <p>
967                      The index of the parameter which is the dependency in the lifetime
968                      relationship to be established. Zero indicates the result object;
969                      1 indicates the first argument. If used to wrap a member function,
970                      parameter 1 is the target object (<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>). Note that if the target
971                      Python object type doesn't support weak references, a Python
972                      TypeError exception will be raised when the C++ object being
973                      wrapped is called.
974                    </p>
975                  </td>
976<td>
977                  </td>
978</tr>
979<tr>
980<td>
981                    <p>
982                      ward
983                    </p>
984                  </td>
985<td>
986                    <p>
987                      A positive compile-time constant of type <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>.
988                    </p>
989                  </td>
990<td>
991                    <p>
992                      The index of the parameter which is the dependent in the lifetime
993                      relationship to be established. Zero indicates the result object;
994                      1 indicates the first argument. If used to wrap a member function,
995                      parameter 1 is the target object (<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>).
996                    </p>
997                  </td>
998<td>
999                  </td>
1000</tr>
1001<tr>
1002<td>
1003                    <p>
1004                      Base
1005                    </p>
1006                  </td>
1007<td>
1008                    <p>
1009                      A model of <a class="link" href="../concepts.html#concepts.callpolicies" title="CallPolicies"><code class="computeroutput"><span class="identifier">CallPolicies</span></code></a>
1010                    </p>
1011                  </td>
1012<td>
1013                    <p>
1014                      Used for policy <a class="link" href="../concepts.html#concepts.callpolicies.callpolicies_composition" title="CallPolicies Composition">composition</a>.
1015                    </p>
1016                  </td>
1017<td>
1018                    <p>
1019                      default_call_policies
1020                    </p>
1021                  </td>
1022</tr>
1023</tbody>
1024</table></div>
1025<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">python</span>
1026<span class="special">{</span>
1027   <span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">custodian</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">ward</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Base</span> <span class="special">=</span> <span class="identifier">default_call_policies</span><span class="special">&gt;</span>
1028   <span class="keyword">struct</span> <span class="identifier">with_custodian_and_ward_postcall</span> <span class="special">:</span> <span class="identifier">Base</span>
1029   <span class="special">{</span>
1030      <span class="keyword">static</span> <span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">postcall</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">args</span><span class="special">,</span> <span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">result</span><span class="special">);</span>
1031   <span class="special">};</span>
1032<span class="special">}}</span>
1033</pre>
1034</div>
1035<div class="section">
1036<div class="titlepage"><div><div><h4 class="title">
1037<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.class_with_custodian_and_ward_p0"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.class_with_custodian_and_ward_p0" title="Class with_custodian_and_ward_postcall static functions">Class
1038          <code class="computeroutput"><span class="identifier">with_custodian_and_ward_postcall</span></code>
1039          static functions</a>
1040</h4></div></div></div>
1041<pre class="programlisting"><span class="identifier">PyObject</span> <span class="special">*</span><span class="identifier">postcall</span><span class="special">(</span><span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">args</span><span class="special">,</span> <span class="identifier">PyObject</span><span class="special">*</span> <span class="identifier">result</span><span class="special">);</span></pre>
1042<div class="variablelist">
1043<p class="title"><b></b></p>
1044<dl class="variablelist">
1045<dt><span class="term">Requires</span></dt>
1046<dd><p>
1047                  <code class="computeroutput"><span class="identifier">PyTuple_Check</span><span class="special">(</span><span class="identifier">args</span><span class="special">)</span>
1048                  <span class="special">!=</span> <span class="number">0</span></code>,
1049                  <code class="computeroutput"><span class="identifier">result</span> <span class="special">!=</span>
1050                  <span class="number">0</span></code>
1051                </p></dd>
1052<dt><span class="term">Effects</span></dt>
1053<dd><p>
1054                  Makes the lifetime of the object indicated by ward dependent on
1055                  the lifetime of the object indicated by custodian.
1056                </p></dd>
1057<dt><span class="term">Returns</span></dt>
1058<dd><p>
1059                  <code class="computeroutput"><span class="number">0</span></code> and <code class="computeroutput"><span class="identifier">PyErr_Occurred</span><span class="special">()</span>
1060                  <span class="special">!=</span> <span class="number">0</span></code>
1061                  upon failure, <code class="computeroutput"><span class="keyword">true</span></code>
1062                  otherwise.
1063                </p></dd>
1064</dl>
1065</div>
1066</div>
1067<div class="section">
1068<div class="titlepage"><div><div><h4 class="title">
1069<a name="function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.example"></a><a class="link" href="models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_with_custodian_and_.example" title="Example">Example</a>
1070</h4></div></div></div>
1071<p>
1072            The following example shows how <code class="computeroutput"><span class="identifier">with_custodian_and_ward_postcall</span></code>
1073            is used by the library to implement <code class="computeroutput"><span class="identifier">return_internal_reference</span></code>
1074          </p>
1075<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">owner_arg</span> <span class="special">=</span> <span class="number">1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Base</span> <span class="special">=</span> <span class="identifier">default_call_policies</span><span class="special">&gt;</span>
1076<span class="keyword">struct</span> <span class="identifier">return_internal_reference</span>
1077    <span class="special">:</span> <span class="identifier">with_custodian_and_ward_postcall</span><span class="special">&lt;</span><span class="number">0</span><span class="special">,</span> <span class="identifier">owner_arg</span><span class="special">,</span> <span class="identifier">Base</span><span class="special">&gt;</span>
1078<span class="special">{</span>
1079   <span class="keyword">typedef</span> <span class="identifier">reference_existing_object</span> <span class="identifier">result_converter</span><span class="special">;</span>
1080<span class="special">};</span>
1081</pre>
1082</div>
1083</div>
1084</div>
1085<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
1086<td align="left"></td>
1087<td align="right"><div class="copyright-footer">Copyright © 2002-2005, 2015 David Abrahams, Stefan Seefeld<p>
1088        Distributed under the Boost Software License, Version 1.0. (See accompanying
1089        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>
1090      </p>
1091</div></td>
1092</tr></table>
1093<hr>
1094<div class="spirit-nav">
1095<a accesskey="p" href="function_documentation.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="models_of_resultconverter.html"><img src="../../images/next.png" alt="Next"></a>
1096</div>
1097</body>
1098</html>
1099