*** empty log message ***
[luabind.git] / doc / out_value.rst
blob443e5a055684f1cca5d4156ea3a4cf3958c741d3
1 out_value
2 ----------------
4 Motivation
5 ~~~~~~~~~~
7 This policy makes it possible to wrap functions that take non-const references
8 or pointer to non-const as it's parameters with the intention to write return 
9 values to them.
11 Defined in
12 ~~~~~~~~~~
14 .. parsed-literal::
16     #include <luabind/out_value_policy.hpp>
18 Synopsis
19 ~~~~~~~~
21 .. parsed-literal::
23     out_value(index, policies = none)
26 Parameters
27 ~~~~~~~~~~
29 =============== =============================================================
30 Parameter       Purpose
31 =============== =============================================================
32 ``index``       The index of the parameter to be used as an out parameter.
33 ``policies``    The policies used internally to convert the out parameter
34                 to/from Lua. ``_1`` means **to** C++, ``_2`` means **from**
35                 C++.
36 =============== =============================================================
38 Example
39 ~~~~~~~
41 .. parsed-literal::
43     void f1(float& val) { val = val + 10.f; }
44     void f2(float\* val) { \*val = \*val + 10.f; }
46     module(L)
47     [
48         def("f", &f, **out_value(_1)**)
49     ];
51     Lua 5.0  Copyright (C) 1994-2003 Tecgraf, PUC-Rio
52     > print(f1(10))
53     20
54     > print(f2(10))
55     20