1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN">
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) -->
8 <meta name=
"generator" content=
9 "HTML Tidy for Windows (vers 1st August 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">
13 <title>Boost.Python -
<boost/python/return_by_value.hpp
></title>
17 <table border=
"0" cellpadding=
"7" cellspacing=
"0" width=
"100%" summary=
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>
26 <h1 align=
"center"><a href=
"../index.html">Boost.Python
</a></h1>
28 <h2 align=
"center">Header
29 <boost/python/return_by_value.hpp
></h2>
37 <dl class=
"page-index">
38 <dt><a href=
"#classes">Classes
</a></dt>
41 <dl class=
"page-index">
42 <dt><a href=
"#return_by_value-spec">Class
43 <code>return_by_value
</code></a></dt>
46 <dl class=
"page-index">
47 <dt><a href=
"#return_by_value-spec-synopsis">Class
48 <code>return_by_value
</code> synopsis
</a></dt>
50 <dt><a href=
"#return_by_value-spec-metafunctions">Class
51 <code>return_by_value
</code> metafunctions
</a></dt>
57 <dt><a href=
"#examples">Example
</a></dt>
61 <h2><a name=
"classes"></a>Classes
</h2>
63 <h3><a name=
"return_by_value-spec"></a>Class
64 <code>return_by_value
</code></h3>
66 <p><code>return_by_value
</code> is a model of
<a href=
67 "ResultConverter.html#ResultConverterGenerator-concept">ResultConverterGenerator
</a>
68 which can be used to wrap C++ functions returning any reference or value
69 type such that the return value is copied into a new Python object.
</p>
71 <h4><a name=
"return_by_value-spec-synopsis"></a>Class
72 <code>return_by_value
</code> synopsis
</h4>
74 namespace boost { namespace python
76 struct return_by_value
78 template
<class T
> struct apply;
83 <h4><a name=
"return_by_value-spec-metafunctions"></a>Class
84 <code>return_by_value
</code> metafunctions
</h4>
86 template
<class T
> struct apply
89 <dl class=
"metafunction-semantics">
90 <dt><b>Returns:
</b> <code>typedef
<a href=
91 "to_python_value.html#to_python_value-spec">to_python_value
</a><T
>
95 <h2><a name=
"examples"></a>Example
</h2>
97 <h3>C++ Module Definition
</h3>
99 #include
<boost/python/module.hpp
>
100 #include
<boost/python/class.hpp
>
101 #include
<boost/python/return_by_value.hpp
>
102 #include
<boost/python/return_value_policy.hpp
>
109 // functions to wrap:
115 using namespace boost::python;
116 template
<class R
>
117 void def_void_function(char const* name, R (*f)())
119 def(name, f, return_value_policy
<return_by_value
>());
122 BOOST_PYTHON_MODULE(my_module)
124 class_
<Bar
>(
"Bar");
125 def_void_function(
"b1", b1);
126 def_void_function(
"b2", b2);
127 def_void_function(
"b3", b3);
133 >>> from my_module import *
134 >>> b = b1() # each of these calls
135 >>> b = b2() # creates a brand
136 >>> b = b3() # new Bar object
140 <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
142 <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
145 <p><i>© Copyright
<a href=
146 "http://www.boost.org/people/dave_abrahams.htm">Dave Abrahams
</a> 2002.
</i></p>