草庐IT

Remove-ItemProperty

全部标签

c++ - 无序集 : remove with move

在c++11中,std::unordered_set容器提供插入重载和新函数emplace,因此它可以与不可复制构造的键一起使用,例如std::unique_ptr。当您想删除其中一个key时会发生什么?autotemp=std::move(*some_iterator)有效吗?是否有一些函数可以让我们同时删除一个元素并将其move到临时文件中?编辑:我试着让它简短​​、甜美和简单,但要更清楚:是否有迭代器适配器(可能是move_iterator?)可以让我从容器中move元素并删除该迭代器?如果不是,为什么不呢?future的c++不应该包含这种接口(interface)吗?情况似乎

c++ - boost 属性树 : Remove a node

如何从boostxml属性树中删除节点?我有这样一个文档:some/foldersome/foldersome/folder我知道如何迭代和打印所有文件夹,但我如何删除其中一项并将xml保存回来? 最佳答案 我可能会尝试:boost::property_tree::ptreept;pt.erase(key); 关于c++-boost属性树:Removeanode,我们在StackOverflow上找到一个类似的问题: https://stackoverflow

c++ - 为什么 std::move() 没有 _Remove_reference 就不能工作?

如您所知,_Remove_reference的存在是为了将T&转换为T或将T&&转换为T。我怀着一种玩乐的心情写了下面的代码,它根本没有像我预期的那样工作,但不知道为什么。templatestruct_Remove_reference{//removereferencetypedef_Ty_Type;staticvoidfunc(){cout//struct_Remove_reference//{//removereference//typedef_Ty_Type;//staticvoidfunc(){cout//struct_Remove_reference//{//removerv

c++ - std::remove_cv 应该在 const T 数组上产生什么类型?

应该是什么类型std::remove_cv生产?int[3]或constint[3]?constint[3]是一个arrayof3constint对吧?,并且没有顶级cv限定符。所以它不应该产生constint[3]吗??最新版本的gcc/libstdc++正在生成int[3]我认为。这是一个错误吗?为什么/为什么不? 最佳答案 N4140§3.9.3[basic.type.qualifier]/p5,强调我的:Cv-qualifiersappliedtoanarraytypeattachtotheunderlyingelement

c++ - lua_pop 与 lua_remove

目前我正在用C++构建自己的脚本VM管理器类。我对Lua&LuaC或C++的任何东西都没有问题,但让我困惑的一个部分是何时使用lua_pop以及何时使用lua_remove。据我了解,lua_pop是自上而下移除多个值(在堆栈上),删除不再需要的数据,而lua_remove是用于从任意有效的堆栈索引中删除单个值(基本上是Lua手册对两者的说明:P)。但我注意到网络上散布的某些代码段混合了lua_pop和lua_remove,但是当我尝试使用lua_pop时而不是lua_remove调用只是删除了顶部堆栈元素,我遇到了问题。那么是否有可能获得关于如何以及何时正确使用这两个功能以及这两个功

c++ - 可以使用 std::remove_pointer 从指针类型中删除所有间接寻址吗?

假设我有..int、int*、int**等。我可以使用std::remove_pointer或类似工具直接输入int吗?谢谢 最佳答案 是的。templatestructremove_all{typedefTtype;};templatestructremove_all{typedeftypenameremove_all::typetype;};std::remove_pointer本身在这里用处不大。 关于c++-可以使用std::remove_pointer从指针类型中删除所有间接寻

c++ - boost::filesystem::remove_all(path) 是如何工作的?

我正在尝试使用boost::filesystem::remove_all(path)从特定路径中删除所有目录、子目录和包含的文件。如果文件在另一个程序中打开,我还想显示一条错误消息。在这种情况下boost::filesystem::remove_all(path)会抛出异常吗?或者有其他方法可以实现吗? 最佳答案 这不适合发表评论,所以我发布为答案只需查看源代码:http://www.boost.org/doc/libs/1_55_0/libs/filesystem/src/operations.cppBOOST_FILESYSTE

c++ - 在 erase-remove 习语中使用一元谓词的否定

考虑以下场景:boolis_odd(inti){return(i%2)!=0;}intmain(){//ignorethemethodofvectorinitializationbelow.//assumeC++11isnottobeused.std::vectorv1={0,1,2,3,4,5,6,7,8,9};std::vectorv2={0,1,2,3,4,5,6,7,8,9};//removesalloddnumbers,OKv1.erase(std::remove_if(v1.begin(),v1.end(),is_odd),v1.end());//removealleven

C++ std::set::erase 与 std::remove_if

此代码有VisualStudioerrorC3892。如果我将std::set更改为std::vector-它有效。std::seta;a.erase(std::remove_if(a.begin(),a.end(),[](intitem){returnitem==10;}),a.end());怎么了?为什么我不能将std::remove_if与std::set一起使用? 最佳答案 您不能使用std::remove_if()具有const的序列部分。std::set的序列元素由Tconst组成对象。事实上,我们昨天在标准C++委员会

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