out_value.rst.svn-base
来自「本人找过多个在linux下c++的lua5.1封装库,但很少.luabind已经」· SVN-BASE 代码 · 共 61 行
SVN-BASE
61 行
out_value----------------Motivation~~~~~~~~~~This policy makes it possible to wrap functions that take non-const referencesor pointer to non-const as it's parameters with the intention to write return values to them. Since it's impossible to pass references to primitive typesin lua, this policy will add another return value with the value after thecall. If the function already has one return value, one instance of thispolicy will add another return value (read about multiple return values inthe lua manual).Defined in~~~~~~~~~~.. parsed-literal:: #include <luabind/out_value_policy.hpp>Synopsis~~~~~~~~.. parsed-literal:: out_value(index, policies = none)Parameters~~~~~~~~~~=============== =============================================================Parameter Purpose=============== =============================================================``index`` The index of the parameter to be used as an out parameter.``policies`` The policies used internally to convert the out parameter to/from Lua. ``_1`` means **to** C++, ``_2`` means **from** C++.=============== =============================================================Example~~~~~~~.. parsed-literal:: void f1(float& val) { val = val + 10.f; } void f2(float\* val) { \*val = \*val + 10.f; } module(L) [ def("f", &f, **out_value(_1)**) ]; Lua 5.0 Copyright (C) 1994-2003 Tecgraf, PUC-Rio > print(f1(10)) 20 > print(f2(10)) 20
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?