summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/sol2/docs/source/api/function.rst
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2016-11-15 22:21:07 -0600
committer cracyc <cracyc@users.noreply.github.com>2016-11-15 22:21:07 -0600
commita68d4239929802bca7131d4b97c2b8d149fbbcb9 (patch)
tree03a497191ccd83206e94c60aca635eb44d51c0f7 /3rdparty/sol2/docs/source/api/function.rst
parent4d533249fdf28d3a473426130a82e673b1b1d5ec (diff)
luaengine: use initializers (nw)
Diffstat (limited to '3rdparty/sol2/docs/source/api/function.rst')
-rw-r--r--3rdparty/sol2/docs/source/api/function.rst8
1 files changed, 6 insertions, 2 deletions
diff --git a/3rdparty/sol2/docs/source/api/function.rst b/3rdparty/sol2/docs/source/api/function.rst
index 93adedabe49..1056bd2fe95 100644
--- a/3rdparty/sol2/docs/source/api/function.rst
+++ b/3rdparty/sol2/docs/source/api/function.rst
@@ -82,13 +82,17 @@ This makes it much easier to work with multiple return values. Using ``std::tie`
Calls the function. The second ``operator()`` lets you specify the templated return types using the ``my_func(sol::types<int, std::string>, ...)`` syntax. Function assumes there are no runtime errors, and thusly will call the ``atpanic`` function if an error does occur.
+
+.. _function-argument-handling:
+
+functions and argument passing
+------------------------------
+
.. note::
All arguments are forwarded. Unlike :doc:`get/set/operator[] on sol::state<state>` or :doc:`sol::table<table>`, value semantics are not used here. It is forwarding reference semantics, which do not copy/move unless it is specifically done by the receiving functions / specifically done by the user.
-.. _function-argument-handling:
-
.. note::
This also means that you should pass and receive arguments in certain ways to maximize efficiency. For example, ``sol::table``, ``sol::object``, ``sol::userdata`` and friends are fairly cheap to copy, and should simply by taken as values. This includes primitive types like ``int`` and ``double``. However, C++ types -- if you do not want copies -- should be taken as ``const type&`` or ``type&``, to save on copies if it's important. Note that taking references from Lua also means you can modify the data inside of Lua directly, so be careful. Lua by default deals with things mostly by reference (save for primitive types).