tags:

views:

146

answers:

1

I have some code using Luabind, and I need to execute a function (from C++) if it's present in the _G table, but otherwise do nothing. How do I detect if a function is present in _G or not?

+1  A: 

Something like this should work:

if (luabind::object f = luabind::globals(L)["f"])
{
    f(...);
}
Daniel Wallin