For my current project, I\'ve been writing a lot of C/C++ to Lua wrappers. A large number of these are simple setters and getters, so I managed to write some templates that
Reusing the indices generation code from this answer and ignoring the function call to Func
(don't know how exactly this is intended to be used), this is how it could look like:
template
int luaU_func_impl(lua_State* L, Collection)
{
luaU_push(L, luaW_check(L, 1), luaU_check(L, Idx+2)...);
return 1;
}
template
int luaU_func(lua_State* L)
{
typename GenerateCollection::type Indices;
return luaU_func_impl(L, Indices);
}