【发布时间】:2016-09-19 05:39:26
【问题描述】:
我想使用 luabridge 将一个函数从一个 Lua_State 复制到另一个。
luabridge 提供了一个名为addFunction(const char * name,FP fp) 的函数和一个名为getGlobal(lua_State* L,const char*) 的函数,它返回一个具有重载运算符的LuaRef 类型的对象。我正在使用 multimap 来存储要复制的函数的名称。
函数addFunction()不支持使用指向类的指针,因此我不能直接传递getGlobal().operator()
//get all functions that match the Criteria
std::pair<acc_map_iter, acc_map_iter> range = sec_map->equal_range(acl);
//Add them to the first State
std::for_each(range.first, range.second, [&](acc_map_iter iter){
script->compilerContext->addFunction(iter->second.c_str(), [&](/*args...?*/)
{
return luabridge::getGlobal(sec_state, iter->second.c_str()).operator(/*args...?*/);
});
});
我能否以某种方式使 lambda 接受来自addFunction() 的多个参数。有什么诀窍还是根本不可能?
【问题讨论】:
-
您的问题有点难以理解,但也许您可以使用
std::bind()? -
对不起,我想这是一个很奇怪的问题。将绑定支持传递可变数量的参数?
标签: c++ lambda arguments luabridge