summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/sol2/docs/source/api
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2016-11-07 13:31:30 -0600
committer cracyc <cracyc@users.noreply.github.com>2016-11-07 13:31:30 -0600
commit673e7536216e6792c3da1a7c800c0edbe8e2f286 (patch)
treeaaf00d33ed2a4097ebbe34cea16163f7ddee50b3 /3rdparty/sol2/docs/source/api
parentd733b5451ace5b45b2009add6495fb894fbb4d44 (diff)
update sol2 (nw)
Diffstat (limited to '3rdparty/sol2/docs/source/api')
-rw-r--r--3rdparty/sol2/docs/source/api/containers.rst14
1 files changed, 12 insertions, 2 deletions
diff --git a/3rdparty/sol2/docs/source/api/containers.rst b/3rdparty/sol2/docs/source/api/containers.rst
index dba03df8a58..81bbdc40584 100644
--- a/3rdparty/sol2/docs/source/api/containers.rst
+++ b/3rdparty/sol2/docs/source/api/containers.rst
@@ -53,7 +53,17 @@ Here's a complete working example of it working for Lua 5.3 and Lua 5.2, and how
return 0;
}
-Note that this will not work well in 5.1, as it has explicit table checks and does not check metamethods, even when ``pairs`` or ``ipairs`` is passed a table. In that case, you will need to use a more manual iteration scheme or you will have to convert it to a table. In C++, you can use :doc:`sol::as_table<as_table>` when passing something to the library to get a table out of it.
+
+Note that this will not work well in Lua 5.1, as it has explicit table checks and does not check metamethods, even when ``pairs`` or ``ipairs`` is passed a table. In that case, you will need to use a more manual iteration scheme or you will have to convert it to a table. In C++, you can use :doc:`sol::as_table<as_table>` when passing something to the library to get a table out of it: ``lua["arr"] = as_table( std::vector<int>{ ... });``. For manual iteration in Lua code without using ``as_table`` for something with indices, try:
+
+.. code-block:: lua
+ :caption: iteration.lua
+
+ for i = 1, #vec do
+ print(i, vec[i])
+ end
+
+There are also other ways to iterate over key/values, but they can be difficult due to not having proper support in Lua 5.1. We recommend that you upgrade to Lua 5.2 or 5.3.
additional functions
@@ -90,4 +100,4 @@ If you have a type that has ``begin`` or ``end`` member functions but don't prov
namespace sol {
template <>
struct is_container<not_container> : std::false_type {};
- } \ No newline at end of file
+ }