From 1e3466d173fb10a760b1c5f7dd37b0b96389a881 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Mon, 29 Sep 2014 23:05:00 -0400 Subject: [PATCH] std::size_t for life. Clang's silly tautological error can die in a fire. D:< --- sol/function_types.hpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/sol/function_types.hpp b/sol/function_types.hpp index e28733e7..d121c8c6 100644 --- a/sol/function_types.hpp +++ b/sol/function_types.hpp @@ -247,7 +247,7 @@ struct base_function { return base_gc(L, *pudata); } - template + template struct userdata { static int call(lua_State* L) { // Zero-based template parameter, but upvalues start at 1 @@ -258,14 +258,25 @@ struct base_function { return ref_base_call(L, stack::get(L, I + 1)); } - static int gc(lua_State* L) { - for(int i = 0; i < I; ++i) { + template + static void func_gc (std::true_type, lua_State* L) { + + } + + template + static void func_gc (std::false_type, lua_State* L) { + // Shut up clang tautological error without throwing out std::size_t + for(std::size_t i = 0; i < limit; ++i) { upvalue_t up = stack::get(L, i + 1); base_function* obj = static_cast(up.value); std::allocator alloc{}; alloc.destroy(obj); alloc.deallocate(obj, 1); } + } + + static int gc(lua_State* L) { + func_gc(std::integral_constant(), L); return 0; } };