Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/doc/v2/raw_function.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: 3.5 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
3<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
4<!-- Software License, Version 1.0. (See accompanying -->
5<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
6<html>
7  <head>
8    <meta name="generator" content=
9    "HTML Tidy for Cygwin (vers 1st April 2002), see www.w3.org">
10    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
11    <link rel="stylesheet" type="text/css" href="../boost.css">
12
13    <title>Boost.Python - &lt;boost/python/raw_function.hpp&gt;</title>
14  </head>
15
16  <body>
17    <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
18    "header">
19      <tr>
20        <td valign="top" width="300">
21          <h3><a href="../../../../index.htm"><img height="86" width="277"
22          alt="C++ Boost" src="../../../../boost.png" border="0"></a></h3>
23        </td>
24
25        <td valign="top">
26          <h1 align="center"><a href="../index.html">Boost.Python</a></h1>
27
28          <h2 align="center">Header &lt;boost/python/raw_function.hpp&gt;</h2>
29        </td>
30      </tr>
31    </table>
32    <hr>
33
34    <h2>Contents</h2>
35
36    <dl class="page-index">
37      <dt><a href="#introduction">Introduction</a></dt>
38
39      <dt><a href="#functions">Functions</a></dt>
40
41      <dd>
42        <dl class="page-index">
43          <dt><a href="#raw_function-spec">raw_function</a></dt>
44        </dl>
45      </dd>
46
47      <dt><a href="#examples">Example</a></dt>
48    </dl>
49    <hr>
50
51    <h2><a name="introduction"></a>Introduction</h2>
52
53    <p><code><a href="#raw_function-spec">raw_function</a>(...)</code>
54    is used to convert a function taking a <a
55    href="tuple.html#tuple-spec">tuple</a> and a <a
56    href="dict.html#dict-spec">dict</a> into a Python callable object
57    which accepts a variable number of arguments and arbitrary keyword
58    arguments.
59
60    <h2><a name="functions"></a>Functions</h2>
61    <a name="raw_function-spec"></a>raw_function
62<pre>
63template &lt;class F&gt;
64object raw_function(F f, std::size_t min_args = 0);
65</pre>
66
67    <dl class="function-semantics">
68      <dt><b>Requires:</b> <code>f(tuple(), dict())</code> is
69      well-formed.</dt>
70
71       <dt><b>Returns:</b> a <a href=
72          "http://www.python.org/doc/current/lib/built-in-funcs.html#l2h-6">callable</a> object which requires at least <code>min_args</code> arguments.  When called, the actual non-keyword arguments will be passed in a <a
73    href="tuple.html#tuple-spec">tuple</a> as the first argument to <code>f</code>, and the keyword arguments will be passed in a  <a
74    href="dict.html#dict-spec">dict</a> as the second argument to <code>f</code>.
75
76      </dd>
77    </dl>
78
79    <h2><a name="examples"></a>Example</h2>
80C++:
81<pre>
82#include &lt;boost/python/def.hpp&gt;
83#include &lt;boost/python/tuple.hpp&gt;
84#include &lt;boost/python/dict.hpp&gt;
85#include &lt;boost/python/module.hpp&gt;
86#include &lt;boost/python/raw_function.hpp&gt;
87
88using namespace boost::python;
89
90tuple raw(tuple args, dict kw)
91{
92    return make_tuple(args, kw);
93}
94
95BOOST_PYTHON_MODULE(raw_test)
96{
97    def("raw", raw_function(raw));
98}
99</pre>
100
101Python:
102<pre>
103&gt;&gt;&gt; from raw_test import *
104
105&gt;&gt;&gt; raw(3, 4, foo = 'bar', baz = 42)
106((3, 4), {'foo': 'bar', 'baz': 42})
107</pre>
108    <p>
109    <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
110     7 March, 2003
111    <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
112    </p>
113
114    <p><i>&copy; Copyright <a href=
115    "../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002.</i></p>
116  </body>
117</html>
118
Note: See TracBrowser for help on using the repository browser.