草庐IT

lua_remove

全部标签

c++ - Lua C API 内存泄漏? (valgrind)

我正在尝试编写一个嵌入了Lua的C程序。而且,我尝试了一个非常简单的程序来启动,它只是创建Lua上下文,然后销毁它:#include#include#include#includeextern"C"{#include#include#include}intmain(intargc,char*argv[]){lua_State*L=lua_open();luaL_openlibs(L);lua_close(L);fprintf(stderr,"%s:%d\n",__FILE__,__LINE__);return(0);}我是这样编译的:(我实际上使用的是Torch7,所以..)g++-c

c++ - 如何以最简单的方式禁用 lua 中的风险函数?

这个问题在这里已经有了答案:关闭11年前。PossibleDuplicates:HowcanIlimitluapossibilities(callingOSfunctions,modules,etc.)HowcanIcreateasecureLuasandbox?luaL_openlibs(m_pState);我使用此函数加载所有库。我想跳过所有危险的库,如IO,但我找不到任何关于如何禁用库的文档。如何禁用某些库?是否有更危险的库可以获得脚本对系统的访问权限?

c++ - std::forward_list::remove_if 谓词的要求

考虑这段代码:structT{boolstatus;UsefulDatadata;};std::forward_listlst;lst.remove_if([](T&x)->bool{returnx.status=!x.status;});即一次性切换状态和删除非事件元素。根据cppreference上面的代码似乎是未定义的行为(强调我的):templatevoidremove_if(UnaryPredicatep);p-unarypredicatewhichreturnstrueiftheelementshouldberemoved.Thesignatureofthepredicat

c++ - Lua - 初始化

这个问题在这里已经有了答案:Whatisanundefinedreference/unresolvedexternalsymbolerrorandhowdoIfixit?(38个答案)关闭8年前。我无法在ArchLinux下正确初始化lua。Lua-最新版本。这是我的代码:#includeextern"C"{#include#include#include}intmain(){lua_State*luaVM=luaL_newstate();if(luaVM==NULL){printf("Errorinitializinglua!\n");return-1;}luaL_openlibs(

c++ - unordered_set::remove_if(): C3892: 无法分配给常量变量

我有这样的代码:unordered_setoutput;...autorequiredType=variables.at(arg.value);autoend=remove_if(output.begin(),output.end(),[&](AttrValuex){return!matchingOutputType(requiredType,ast->getNodeType(ast->getNodeKeyAttribute(x)));});//queryevaluator_getcandidatelist.cpp(179)output.erase(end);错误在代码的第4行。所以我

c++ - 运算符== 和 list::remove()

测试.h#ifndefTEST_H#defineTEST_H#includetemplatebooloperator==(conststd::weak_ptr&wp1,conststd::weak_ptr&wp2){std::shared_ptrsp1;if(!wp1.expired())sp1=wp1.lock();std::shared_ptrsp2;if(!wp2.expired())sp2=wp2.lock();returnsp1==sp2;}#endif测试.cpp#include"Test.h"#includeintmain(){typedefstd::list>intLi

c++ - Lua:这会导致段错误吗

我正在开发一个使用Lua编写脚本的程序,有时它会崩溃。使用GDB我想我发现了问题,但我不知道它是否解决了它,因为段错误只会偶尔发生。所以,旧代码是这样的:voidCall(std::stringfunc){lua_getglobal(L,func.c_str());//ThisisthelineGDBmentionedinabacktraceif(lua_isfunction(L,lua_gettop(L))){interr=lua_pcall(L,0,0,0);if(err!=0){std::cout问题是,这个函数每秒会被调用几次,但它需要调用的函数并不总是被定义,所以我认为堆栈会

c++ - remove_reference 如何禁用模板参数推导?

根据thislink,std::forward不允许模板参数推导,而std::remove_reference正在帮助我们实现这一目标。但是,使用remove_reference如何防止此处发生模板推导?templateS&&forward(typenamestd::remove_reference::type&t)noexcept{returnstatic_cast(t);} 最佳答案 S在表达式typenamestd::remove_reference::type中是一个非推导上下文(特别是因为S出现在使用qualified-i

c++ - 如何遍历 luabind 类(在 lua 或 c++ 中)?

如何遍历luabind类(在lua或c++中)?class'A'functionA:__init()--Doesnotwork--selfisuserdata,notatablefori,vinpairs(self)doendend谢谢 最佳答案 如果您尝试查找有关变量的反射信息(方法列表等),则可以使用class_info()和class_names()功能。注意:据我所知,这些函数没有记录,但它们至少存在于Luabind0.9中。使用风险自负。要在您的Lua代码中使用这些Luabind函数,您需要先绑定(bind)它们。示例:#

c++ - remove_vertex 当图 VertexList=vecS

我有一个带有VertexList=vecS的boost图。typedefadjacency_listTracksConnectionGraph;现在我想遍历我的顶点并删除那些具有特定属性的顶点。我该怎么做?问题是每当我调用remove_vertex时,图中顶点的迭代器以及顶点描述符都会失效。 最佳答案 可能是,在迭代之前,您可以创建特殊的“Trash”顶点,在迭代期间,您将所有要删除的节点连接到该Trash-顶点,并在迭代后删除所有“Trash-connected”顶点? 关于c++-r