From 6ae78d9ed884bb0cf7c32c3669632988a87f874b Mon Sep 17 00:00:00 2001 From: Ilya Averyanov Date: Mon, 22 Jan 2018 16:36:36 +0300 Subject: [PATCH] Use std::bitset instead std::array of bool --- sol/usertype_metatable.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sol/usertype_metatable.hpp b/sol/usertype_metatable.hpp index 56baa424..01aa8c87 100644 --- a/sol/usertype_metatable.hpp +++ b/sol/usertype_metatable.hpp @@ -40,6 +40,7 @@ #include #include #include +#include namespace sol { namespace usertype_detail { @@ -399,7 +400,7 @@ namespace sol { void* baseclasscheck; void* baseclasscast; bool secondarymeta; - std::array properties; + std::bitset<32> properties; template >> = meta::enabler> lua_CFunction make_func() const { @@ -464,12 +465,11 @@ namespace sol { luaL_Reg reg = usertype_detail::make_reg(std::forward(n), make_func()); for (std::size_t i = 0; i < properties.size(); ++i) { meta_function mf = static_cast(i); - bool& prop = properties[i]; const std::string& mfname = to_string(mf); if (mfname == reg.name) { switch (mf) { case meta_function::construct: - if (prop) { + if (properties[i]) { #ifndef SOL_NO_EXCEPTIONS throw error("sol: 2 separate constructor (new) functions were set on this type. Please specify only 1 sol::meta_function::construct/'new' type AND wrap the function in a sol::factories/initializers call, as shown by the documentation and examples, otherwise you may create problems"); #else @@ -490,17 +490,17 @@ namespace sol { case meta_function::index: indexfunc = reg.func; mustindex = true; - prop = true; + properties.set(i); return; case meta_function::new_index: newindexfunc = reg.func; mustindex = true; - prop = true; + properties.set(i); return; default: break; } - prop = true; + properties.set(i); break; } } @@ -511,7 +511,7 @@ namespace sol { template > usertype_metatable(Args&&... args) : usertype_metatable_core(&usertype_detail::indexing_fail, &usertype_detail::metatable_newindex), usertype_detail::registrar(), functions(std::forward(args)...), destructfunc(nullptr), callconstructfunc(nullptr), indexbase(&core_indexing_call), newindexbase(&core_indexing_call), indexbaseclasspropogation(usertype_detail::walk_all_bases), newindexbaseclasspropogation(usertype_detail::walk_all_bases), baseclasscheck(nullptr), baseclasscast(nullptr), secondarymeta(contains_variable()), properties() { - properties.fill(false); + properties.reset(); std::initializer_list ilist{{std::pair(usertype_detail::make_string(std::get(functions)), usertype_detail::call_information(&usertype_metatable::real_find_call, &usertype_metatable::real_find_call))}...};