2
0
mirror of https://github.com/boostorg/python.git synced 2026-02-01 08:42:16 +00:00
Files
python/doc/html/reference/high_level_components/def_hpp/functions.html
2015-08-05 07:21:49 -04:00

181 lines
10 KiB
HTML

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Functions</title>
<link rel="stylesheet" href="../../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="../../index.html" title="Boost.Python Reference Manual">
<link rel="up" href="../def_hpp.html" title="def.hpp">
<link rel="prev" href="../def_hpp.html" title="def.hpp">
<link rel="next" href="example.html" title="Example">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../images/boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../def_hpp.html"><img src="../../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../def_hpp.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="example.html"><img src="../../../images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="high_level_components.def_hpp.functions"></a><a class="link" href="functions.html" title="Functions">Functions</a>
</h3></div></div></div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">def</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">F</span> <span class="identifier">f</span><span class="special">);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Fn</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">def</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Fn</span> <span class="identifier">fn</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span><span class="special">&amp;);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Fn</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A2</span><span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">def</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Fn</span> <span class="identifier">fn</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span><span class="special">&amp;,</span> <span class="identifier">A2</span> <span class="keyword">const</span><span class="special">&amp;);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Fn</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A3</span><span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">def</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Fn</span> <span class="identifier">fn</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span><span class="special">&amp;,</span> <span class="identifier">A2</span> <span class="keyword">const</span><span class="special">&amp;,</span> <span class="identifier">A3</span> <span class="keyword">const</span><span class="special">&amp;);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Requires</span></dt>
<dd>
<p>
name is an ntbs which conforms to Python's identifier naming rules.
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
If <code class="computeroutput"><span class="identifier">Fn</span></code> is [derived
from] object, it will be added to the current scope as a single
overload. To be useful, fn should be callable.
</li>
<li class="listitem">
<p class="simpara">
If a1 is the result of an overload-dispatch-expression, only
the second form is allowed and fn must be a pointer to function
or pointer to member function whose arity is the same as A1's
maximum arity.
</p>
<p class="simpara">
<span class="bold"><strong>Effects:</strong></span> For each prefix P of
Fn's sequence of argument types, beginning with the one whose
length is A1's minimum arity, adds a name(...) function overload
to the current scope. Each overload generated invokes a1's call-expression
with P, using a copy of a1's call policies. If the longest valid
prefix of A1 contains N types and a1 holds M keywords, an initial
sequence of the keywords are used for all but the first N - M
arguments of each overload.
</p>
</li>
<li class="listitem">
<p class="simpara">
Otherwise, fn must be a non-null function or member function
pointer, and a single function overload built around fn is added
to the current scope. If any of a1-a3 are supplied, they may
be selected in any order from the table below.
</p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Mnemonic Name
</p>
</th>
<th>
<p>
Requirements/Type properties
</p>
</th>
<th>
<p>
Effects
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
docstring
</p>
</td>
<td>
<p>
Any ntbs
</p>
</td>
<td>
<p>
Value will be bound to the __doc__ attribute of the
resulting method overload.
</p>
</td>
</tr>
<tr>
<td>
<p>
policies
</p>
</td>
<td>
<p>
A model of CallPolicies
</p>
</td>
<td>
<p>
A copy will be used as the call policies of the resulting
method overload.
</p>
</td>
</tr>
<tr>
<td>
<p>
keywords
</p>
</td>
<td>
<p>
The result of a keyword-expression specifying no more
arguments than the arity of fn.
</p>
</td>
<td>
<p>
A copy will be used as the call policies of the resulting
method overload.
</p>
</td>
</tr>
</tbody>
</table></div>
</li>
</ul></div>
</dd>
</dl>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2015 David Abrahams, Stefan Seefeld<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../def_hpp.html"><img src="../../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../def_hpp.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="example.html"><img src="../../../images/next.png" alt="Next"></a>
</div>
</body>
</html>