【问题标题】:Luabind conditionally calling Lua functionLuabind 有条件地调用 Lua 函数
【发布时间】:2011-01-14 16:27:14
【问题描述】:

我有一些使用 Luabind 的代码,如果它存在于 _G 表中,我需要执行一个函数(来自 C++),否则什么也不做。如何检测_G中是否存在函数?

【问题讨论】:

    标签: lua luabind


    【解决方案1】:

    这样的事情应该可以工作:

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

    【讨论】:

      猜你喜欢
      • 2016-02-15
      • 2011-09-12
      • 2012-03-14
      • 1970-01-01
      • 2011-11-18
      • 2013-05-22
      • 2014-08-05
      • 2020-08-04
      • 1970-01-01
      相关资源
      最近更新 更多