Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

updated boost from 1_33_1 to 1_34_1

File size: 2.9 KB
Line 
1<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
2<!-- Software License, Version 1.0. (See accompanying -->
3<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
4<html>
5<head>
6<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
7<link rel="stylesheet" type="text/css" href="../boost.css">
8<title>Boost.Python - &lt;call.hpp&gt;</title>
9</head>
10<body link="#0000ff" vlink="#800080">
11<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
12    "header">
13  <tr> 
14    <td valign="top" width="300"> 
15          <h3><a href="../../../../index.htm"><img height="86" width="277" alt=
16          "C++ Boost" src="../../../../boost.png" border="0"></a></h3>
17    </td>
18    <td valign="top"> 
19      <h1 align="center"><a href="../index.html">Boost.Python</a></h1>
20      <h2 align="center">Header &lt;call.hpp&gt;</h2>
21    </td>
22  </tr>
23</table>
24<hr>
25<h2>Contents</h2>
26<dl class="page-index"> 
27  <dt><a href="#introduction">Introduction</a></dt>
28  <dt><a href="#functions">Functions</a></dt>
29  <dl class="page-index">
30    <dt><a href="#call-spec">call</a></dt>
31  </dl>
32
33  <dt><a href="#examples">Example(s)</a></dt>
34
35</dl>
36<hr>
37<h2><a name="introduction"></a>Introduction</h2>
38<p>
39  <code>&lt;boost/python/call.hpp&gt;</code> defines the <a
40  href="#call-spec"><code>call</code></a> family of overloaded function
41  templates, used to invoke Python callable objects from C++.
42
43<h2><a name="functions"></a>Functions</h2>
44<pre>
45<a name="call-spec">template &lt;class R, class A1, class A2, ... class A<i>n</i>&gt;</a>
46R call(PyObject* callable, A1 const&amp;, A2 const&amp;, ... A<i>n</i> const&amp;)
47</pre>
48<dl class="function-semantics"> 
49  <dt><b>Requires:</b> <code>R</code> is a pointer type, reference
50  type, or a complete type with an accessible copy constructor</dt>
51
52  <dt><b>Effects:</b> Invokes <code>callable(a1,&nbsp;a2,&nbsp;...a<i>n</i>)</code> in
53  Python, where <code>a1</code>...<code>a<i>n</i></code> are the arguments to
54  <code>call()</code>, converted to Python objects.
55  <dt><b>Returns:</b> The result of the Python call, converted to the C++ type <code>R</code>.</dt>
56
57</dt>
58  <dt><b>Rationale:</b> For a complete semantic description and
59  rationale, see <a href="callbacks.html">this page</a>.
60</dt>
61</dl>
62
63<h2><a name="examples"></a>Example(s)</h2>
64
65The following C++ function applies a Python callable object to its two
66arguments and returns the result. If a Python exception is raised or
67the result can't be converted to a <code>double</code>, an exception
68is thrown.
69
70<pre>
71double apply2(PyObject* func, double x, double y)
72{
73   return boost::python::call&lt;double&gt;(func, x, y);
74}
75</pre>
76
77<p>Revised
78  <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
79  9 May, 2002 <!-- Luann's birthday! -->
80  <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
81</p>
82<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave Abrahams</a> 
83  2002. </i></p>
84</body>
85</html>
Note: See TracBrowser for help on using the repository browser.