Please add luaU_optfield<U>(...)

Issue #14 resolved
qwer1304 NA
created an issue

It'd be helpful to have luaU_optfield<U>(...).

Possible implementation:

template <typename U>
inline U luaU_optfield(lua_State* L, int index, const char* field, const U& fallback = U())
#ifndef LUAW_NO_CXX11
    static_assert(!LUAW_STD::is_same<U, const char*>::value,
        "luaU_getfield is not safe to use on const char*'s. (The string will be popped from the stack.)");
    lua_getfield(L, index, field);
    U val = luaU_opt<U>(L, -1, fallback);
    lua_pop(L, 1);
    return val;

Comments (2)

  1. Log in to comment