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/static_variables.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/static_variables.cpp')
-rw-r--r-- | 3rdparty/sol2/examples/static_variables.cpp | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/3rdparty/sol2/examples/static_variables.cpp b/3rdparty/sol2/examples/static_variables.cpp deleted file mode 100644 index c101e824484..00000000000 --- a/3rdparty/sol2/examples/static_variables.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include <sol.hpp> - -#include <iostream> -#include <cassert> - -struct test { - static int muh_variable; -}; -int test::muh_variable = 25; - - -int main() { - std::cout << "=== static_variables example ===" << std::endl; - - sol::state lua; - lua.open_libraries(); - lua.new_usertype<test>("test", - "direct", sol::var(2), - "global", sol::var(test::muh_variable), - "ref_global", sol::var(std::ref(test::muh_variable)) - ); - - int direct_value = lua["test"]["direct"]; - // direct_value == 2 - assert(direct_value == 2); - std::cout << "direct_value: " << direct_value << std::endl; - - int global = lua["test"]["global"]; - int global2 = lua["test"]["ref_global"]; - // global == 25 - // global2 == 25 - assert(global == 25); - assert(global2 == 25); - - std::cout << "First round of values --" << std::endl; - std::cout << global << std::endl; - std::cout << global2 << std::endl; - - test::muh_variable = 542; - - global = lua["test"]["global"]; - // global == 25 - // global is its own memory: was passed by value - - global2 = lua["test"]["ref_global"]; - // global2 == 542 - // global2 was passed through std::ref - // global2 holds a reference to muh_variable - // if muh_variable goes out of scope or is deleted - // problems could arise, so be careful! - - assert(global == 25); - assert(global2 == 542); - - std::cout << "Second round of values --" << std::endl; - std::cout << "global : " << global << std::endl; - std::cout << "global2: " << global2 << std::endl; - std::cout << std::endl; - - return 0; -} |