usertype destructor needs to be of the right type for non-const values

This commit is contained in:
ThePhD 2018-09-28 04:43:06 -07:00
parent 72b9d91c14
commit 015ef6a37a
No known key found for this signature in database
GPG Key ID: 1509DB1C0F702BFA

View File

@ -191,7 +191,7 @@ namespace sol {
return &detail::unique_destruct<T>; return &detail::unique_destruct<T>;
} }
else if constexpr (!std::is_pointer_v<T>) { else if constexpr (!std::is_pointer_v<T>) {
return &detail::unique_destruct<T>; return &detail::usertype_alloc_destruct<T>;
} }
} }
else { else {
@ -274,15 +274,15 @@ namespace sol {
void operator()() const { void operator()() const {
if (luaL_newmetatable(L, key) == 1) { if (luaL_newmetatable(L, key) == 1) {
luaL_Reg l[64]{}; luaL_Reg l[64] {};
int index = 0; int index = 0;
auto prop_fx = [](meta_function) { return true; }; auto prop_fx = [](meta_function) { return true; };
auto insert_fx = [&l, &index](meta_function mf, lua_CFunction f) { auto insert_fx = [&l, &index](meta_function mf, lua_CFunction f) {
l[index] = luaL_Reg{ to_string(mf).c_str(), f }; l[index] = luaL_Reg { to_string(mf).c_str(), f };
++index; ++index;
}; };
u_detail::insert_default_registrations<P>(insert_fx, prop_fx); u_detail::insert_default_registrations<P>(insert_fx, prop_fx);
l[index] = luaL_Reg{ to_string(meta_function::garbage_collect).c_str(), u_detail::make_destructor<P>() }; l[index] = luaL_Reg { to_string(meta_function::garbage_collect).c_str(), u_detail::make_destructor<P>() };
luaL_setfuncs(L, l, 0); luaL_setfuncs(L, l, 0);
// __type table // __type table