11<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2- < meta name ="generator " content ="HTML Tidy, see www.w3.org ">
2+
3+ < html >
4+ < head >
5+ < meta name ="generator " content =
6+ "HTML Tidy for Windows (vers 1st August 2002), see www.w3.org ">
37 < meta http-equiv ="Content-Type " content ="text/html; charset=iso-8859-1 ">
48 < link rel ="stylesheet " type ="text/css " href ="../boost.css ">
59
610 < title > Boost.Python - <boost/python/make_function.hpp></ title >
11+ </ head >
712
13+ < body >
814 < table border ="0 " cellpadding ="7 " cellspacing ="0 " width ="100% " summary =
915 "header ">
1016 < tr >
1117 < td valign ="top " width ="300 ">
12- < h3 > < a href ="../../../../index.htm "> < img height ="86 " width ="277 " alt =
13- "C++ Boost " src ="../../../../c++boost.gif " border ="0 "> </ a > </ h3 >
18+ < h3 > < a href ="../../../../index.htm "> < img height ="86 " width ="277 "
19+ alt ="C++ Boost " src ="../../../../c++boost.gif " border ="0 "> </ a > </ h3 >
20+ </ td >
1421
1522 < td valign ="top ">
1623 < h1 align ="center "> Boost.Python</ h1 >
1724
18- < h2 align ="center "> Header <boost/python/make_function.hpp></ h2 >
25+ < h2 align ="center "> Header
26+ <boost/python/make_function.hpp></ h2 >
27+ </ td >
28+ </ tr >
1929 </ table >
2030 < hr >
2131
2232 < h2 > Contents</ h2 >
2333
2434 < dl class ="page-index ">
25- < dt > < a href ="#introduction "> Introduction</ a >
35+ < dt > < a href ="#introduction "> Introduction</ a > </ dt >
2636
27- < dt > < a href ="#functions "> Functions</ a >
37+ < dt > < a href ="#functions "> Functions</ a > </ dt >
2838
2939 < dd >
3040 < dl class ="page-index ">
31- < dt > < a href ="#make_function-spec "> make_function</ a >
41+ < dt > < a href ="#make_function-spec "> make_function</ a > </ dt >
3242
33- < dt > < a href ="#make_constructor-spec "> make_constructor</ a >
43+ < dt > < a href ="#make_constructor-spec "> make_constructor</ a > </ dt >
3444 </ dl >
45+ </ dd >
3546
36- < dt > < a href ="#examples "> Example</ a >
47+ < dt > < a href ="#examples "> Example</ a > </ dt >
3748 </ dl >
3849 < hr >
3950
4051 < h2 > < a name ="introduction "> </ a > Introduction</ h2 >
4152
4253 < p > < code > < a href ="#make_function-spec "> make_function</ a > ()</ code > and
4354 < code > < a href ="#make_constructor-spec "> make_constructor</ a > ()</ code > are
44- the functions used internally by < code > class_<>::< a href =
45- "class.html#class_-spec-modifiers "> def</ a > </ code > , < code > class_<>::< a
46- href ="module.html#module-spec-modifiers "> def</ a > </ code > , and
47- < code > class_<>::< a href =
48- "class.html#class_-spec-modifiers "> def_init</ a > </ code > to produce Python
49- callable objects which wrap C++ functions and member functions.
55+ the functions used internally by < code > < a href =
56+ "def.html#def-spec "> def</ a > ()</ code > and < code > class_<>::< a href =
57+ "class.html#class_-spec-modifiers "> def</ a > ()</ code > to produce Python
58+ callable objects which wrap C++ functions and member functions.</ p >
5059
5160 < h2 > < a name ="functions "> </ a > Functions</ h2 >
5261< pre >
5362< a name ="make_function-spec "> template <class F></ a >
54- objects::function* make_function(F f)
63+ < a href =" object.html#object-spec " > object </ a > make_function(F f)
5564
5665template <class F, class Policies>
57- objects::function* make_function(F f, Policies const& policies)
66+ < a href =
67+ "object.html#object-spec "> object</ a > make_function(F f, Policies const& policies)
68+
69+ template <class F, class Policies, class Keywords>
70+ < a href =
71+ "object.html#object-spec "> object</ a > make_function(F f, Policies const& policies, Keywords const& keywords)
5872</ pre >
5973
6074 < dl class ="function-semantics ">
6175 < dt > < b > Requires:</ b > < code > F</ code > is a function pointer or member
62- function pointer type
76+ function pointer type. If < code > policies</ code > are supplied, it must
77+ be a model of < a href ="CallPolicies.html "> CallPolicies</ a > . If
78+ < code > kewords</ code > are supplied, it must be the result of a < a href =
79+ "args.html#keyword-expression "> < em > keyword-expression</ em > </ a >
80+ specifying no more arguments than the < a href =
81+ "definitions.html#arity "> arity</ a > of < code > f</ code > .</ dt >
6382
6483 < dt > < b > Effects:</ b > Creates a Python callable object which, when called
6584 from Python, converts its arguments to C++ and calls < code > f</ code > . If
66- < code > F</ code > is a pointer-to-member-function type, the target object of
67- the function call (< code > *this</ code > ) will be taken from the first
85+ < code > F</ code > is a pointer-to-member-function type, the target object
86+ of the function call (< code > *this</ code > ) will be taken from the first
6887 Python argument, and subsequent Python arguments will be used as the
6988 arguments to < code > f</ code > . If < code > policies</ code > are supplied, it
70- must be a model of < a href ="CallPolicies.html "> CallPolicies</ a > , and will
71- be applied to the function as described < a href =
72- "CallPolicies.html "> here</ a > .
73-
74- < dt > < b > Returns:</ b > A pointer convertible to < code > PyObject*</ code > which
75- refers to the new Python callable object.
89+ will be applied to the function as described < a href =
90+ "CallPolicies.html "> here</ a > . If < code > keywords</ code > are
91+ supplied, the keywords will be applied in order to the final
92+ arguments of the resulting function.</ dt >
93+
94+ < dt > < b > Returns:</ b > An instance of < a href =
95+ "object.html#object-spec "> object</ a > which holds the new Python
96+ callable object.</ dt >
7697 </ dl >
7798< pre >
7899< a name =
79- "make_constructor-spec "> template <class T, class ArgList, class Generator>
80- objects::function* make_constructor(); </ a >
81-
100+ "make_constructor-spec "> </ a > template <class T, class ArgList, class Generator>
101+ < a href =" object.html#object-spec " > object </ a > make_constructor();
102+
82103template <class ArgList, class Generator, class Policies>
83- objects::function* make_constructor(Policies const& policies)
104+ < a href =
105+ "object.html#object-spec "> object</ a > make_constructor(Policies const& policies)
84106</ pre >
85107
86108 < dl class ="function-semantics ">
87- < dt > < b > Requires:</ b > < code > T</ code > is a class
88- type. < code > Policies</ code > is a model of < a
89- href = "CallPolicies.html "> CallPolicies</ a > . < code > ArgList</ code >
90- is an < a href ="../../../mpl/doc/Sequences.html "> MPL sequence</ a >
91- of C++ argument types (< i > A1, A2,... AN</ i > ) such that if
92- < code > a1, a2</ code > ... < code > aN</ code > are objects of type
93- < i > A1, A2,... AN</ i > respectively, the expression < code > new
94- Generator::apply<T>::type(a1, a2</ code > ... < code > aN</ code > ) is
95- valid. Generator is a model of < a href =
96- "HolderGenerator.html "> HolderGenerator</ a > .
109+ < dt > < b > Requires:</ b > < code > T</ code > is a class type.
110+ < code > Policies</ code > is a model of < a href =
111+ "CallPolicies.html "> CallPolicies</ a > . < code > ArgList</ code > is an < a
112+ href ="../../../mpl/doc/Sequences.html "> MPL sequence</ a > of C++ argument
113+ types (< i > A1, A2,... AN</ i > ) such that if
114+ < code > a1, a2</ code > ... < code > aN</ code > are objects of type
115+ < i > A1, A2,... AN</ i > respectively, the expression < code > new
116+ Generator::apply<T>::type(a1, a2</ code > ... < code > aN</ code > )
117+ is valid. Generator is a model of < a href =
118+ "HolderGenerator.html "> HolderGenerator</ a > .</ dt >
97119
98120 < dt > < b > Effects:</ b > Creates a Python callable object which, when called
99121 from Python, expects its first argument to be a Boost.Python extension
100122 class object. It converts its remaining its arguments to C++ and passes
101123 them to the constructor of a dynamically-allocated
102- < code > Generator::apply<T>::type</ code > object, which is
103- then installed in the extension class object. In the second
104- form, the < code > policies</ code > are applied to the arguments and
105- result (< a
106- href ="http://www.python.org/doc/current/lib/bltin-null-object.html "> None</ a > )
107- of the Python callable object
108-
109- < dt > < b > Returns:</ b > The new Python callable object
124+ < code > Generator::apply<T>::type</ code > object, which is then
125+ installed in the extension class object. In the second form, the
126+ < code > policies</ code > are applied to the arguments and result (< a href =
127+ "http://www.python.org/doc/current/lib/bltin-null-object.html "> None</ a > )
128+ of the Python callable object</ dt >
129+
130+ < dt > < b > Returns:</ b > An instance of < a href =
131+ "object.html#object-spec "> object</ a > which holds the new Python
132+ callable object.</ dt >
110133 </ dl >
111134
112135 < h2 > < a name ="examples "> </ a > Example</ h2 >
113136
114- < p > C++ function exposed below returns a callable object wrapping one of two
115- functions.
137+ < p > C++ function exposed below returns a callable object wrapping one of
138+ two functions.</ p >
116139< pre >
117140#include <boost/python/make_function.hpp>
118- #include <boost/python/module .hpp>
141+ #include <boost/python/module_init .hpp>
119142
120143char const* foo() { return "foo"; }
121144char const* bar() { return "bar"; }
122145
123- PyObject* choose_function(bool selector)
146+ using namespace boost::python;
147+ object choose_function(bool selector)
124148{
125149 if (selector)
126150 return boost::python::make_function(foo);
@@ -130,8 +154,7 @@ <h2><a name="examples"></a>Example</h2>
130154
131155BOOST_PYTHON_MODULE_INIT(make_function_test)
132156{
133- module("make_function_test")
134- .def("choose_function", choose_function);
157+ def("choose_function", choose_function);
135158}
136159</ pre >
137160 It can be used this way in Python:
@@ -147,9 +170,13 @@ <h2><a name="examples"></a>Example</h2>
147170
148171 < p >
149172 <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
150- 14 February 2002 <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
151-
152-
153- < p > < i > © Copyright < a href ="../../../../people/dave_abrahams.htm "> Dave
154- Abrahams</ a > 2002. All Rights Reserved.</ i >
173+ 29 September 2002
174+ <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
175+ </ p >
176+
177+ < p > < i > © Copyright < a href =
178+ "../../../../people/dave_abrahams.htm "> Dave Abrahams</ a > 2002. All Rights
179+ Reserved.</ i > </ p >
180+ </ body >
181+ </ html >
155182
0 commit comments