⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 return_reference_to.rst.svn-base

📁 本人找过多个在linux下c++的lua5.1封装库,但很少.luabind已经release的版本只支持lua5.0.这个版本是我从其cvs(svc)上取出的并支持最新的lua5.1.强烈推荐.
💻 SVN-BASE
字号:
return_reference_to-------------------Motivation~~~~~~~~~~It is very common to return references to arguments or the this-pointer toallow for chaining in C++.::    struct A    {        float val;        A& set(float v)        {            val = v;            return *this;        }    };When luabind generates code for this, it will create a new object for thereturn-value, pointing to the self-object. This isn't a problem, but could be abit inefficient. When using the return_reference_to-policy we have the abilityto tell luabind that the return-value is already on the lua stack.Defined in~~~~~~~~~~.. parsed-literal::    #include <luabind/return_reference_to_policy.hpp>Synopsis~~~~~~~~.. parsed-literal::    return_reference_to(index)Parameters~~~~~~~~~~========= =============================================================Parameter Purpose========= =============================================================``index`` The argument index to return a reference to, any argument but          not ``result``.========= =============================================================Example~~~~~~~.. parsed-literal::    struct A    {        float val;        A& set(float v)        {            val = v;            return \*this;        }    };    module(L)    [        class_<A>("A")            .def(constructor<>())            .def("set", &A::set, **return_reference_to(_1)**)    ];.. warning::    This policy ignores all type information and should be used only it    situations where the parameter type is a perfect match to the    return-type (such as in the example).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -