diff options
author | 2020-11-15 03:53:47 +1100 | |
---|---|---|
committer | 2020-11-15 03:53:47 +1100 | |
commit | 55b8ca317ab1f77850f498c1523355e1f5dd8d03 (patch) | |
tree | bada7948236b18684609f47024cc9ca227a5ef89 /3rdparty/sol2/examples/variadic_args.cpp | |
parent | 4db7f0439c3b841eb07d2320e39be38269e6cd56 (diff) |
-Switch to building MAME as C++17.
* Updated sol2 to 3.2.2
* Updated pugixml to 1.10
* Increased minimum clang version to 6
* Cleaned up some stuff that can use new features
Diffstat (limited to '3rdparty/sol2/examples/variadic_args.cpp')
-rw-r--r-- | 3rdparty/sol2/examples/variadic_args.cpp | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/3rdparty/sol2/examples/variadic_args.cpp b/3rdparty/sol2/examples/variadic_args.cpp deleted file mode 100644 index 918e33ec790..00000000000 --- a/3rdparty/sol2/examples/variadic_args.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include <sol.hpp> - -#include <iostream> - -int main() { - std::cout << "=== variadic_args example ===" << std::endl; - - sol::state lua; - lua.open_libraries(sol::lib::base); - - // Function requires 2 arguments - // rest can be variadic, but: - // va will include everything after "a" argument, - // which means "b" will be part of the varaidic_args list too - // at position 0 - lua.set_function("v", [](int a, sol::variadic_args va, int /*b*/) { - int r = 0; - for (auto v : va) { - int value = v; // get argument out (implicit conversion) - // can also do int v = va.get<int>(i); with index i - r += value; - } - // Only have to add a, b was included from variadic_args and beyond - return r + a; - }); - - lua.script("x = v(25, 25)"); - lua.script("x2 = v(25, 25, 100, 50, 250, 150)"); - lua.script("x3 = v(1, 2, 3, 4, 5, 6)"); - // will error: not enough arguments - //lua.script("x4 = v(1)"); - - lua.script("assert(x == 50)"); - lua.script("assert(x2 == 600)"); - lua.script("assert(x3 == 21)"); - lua.script("print(x)"); // 50 - lua.script("print(x2)"); // 600 - lua.script("print(x3)"); // 21 - std::cout << std::endl; -}
\ No newline at end of file |