sol2/examples/source/docs/as_table_ipairs.cpp
ThePhD 8618e39486
🛠 Prepare for the a sol4 release...
- 🎨 Refactor the CMake a whle bunch
2021-03-06 01:03:23 -05:00

15 lines
319 B
C++

#define SOL_ALL_SAFETIES_ON 1
#include <sol/sol.hpp>
#include <vector>
int main(int, char*[]) {
sol::state lua;
lua.open_libraries();
lua.set("my_table", sol::as_table(std::vector<int> { 1, 2, 3, 4, 5 }));
lua.script("for k, v in ipairs(my_table) do print(k, v) assert(k == v) end");
return 0;
}