如何使用 yaml-cpp 0.5.0 API 从列表中删除元素
How to remove an element from list using the yaml-cpp 0.5.0 API
以下测试代码不会按预期从列表中删除元素:
YAML::Node node = YAML::Load("[1,2,3]");
node.remove(1); // expect that this should remove the middle element from the list
ofstream ofs("test.yml");
ofs << node;
ofs.close();
测试输出文件包含:
-1
-2
-3
该文件似乎包含原始列表中的值,并且未删除该元素。从列表中删除元素的正确方法是什么?
现在没有办法做到这一点(我没有想到这个!我已经提交了一个错误(http://code.google.com/p/yaml-cpp/issues/detail?id=190),但我不确定语法应该是什么。如果您有建议,请对该问题发表评论!
相关文章:
- 从链接列表c++中删除一个项目
- C++如何通过用户输入删除列表元素
- 从嵌套在std::映射中的std::列表中删除元素的最佳方式
- 删除列表中的第n个元素
- 你能检查一下为什么在这个代码中从链接列表中删除项目不起作用吗
- 从类型列表中递归删除重复项会导致编译器堆空间错误 (VS2017)
- 如何在不强制转换每个参数的情况下删除初始值设定项列表中从 int 到 char 的缩小转换?
- 删除列表 c++ 中的最后 3 个元素
- 为什么每当我尝试运行此链接列表删除功能时都会收到分段错误错误?
- 我可以从列表中获取对象并复制它们,但如何删除我复制的对象?
- 动态分配列表 - 创建一个函数,用于删除所有包含偶数值的元素
- C++ 从具有开始位置和结束位置的列表中删除
- 从列表向量中删除无法按预期工作
- 从列表C++中删除对象
- 简单的链接列表删除失败
- C++循环链接列表 - 删除所有节点
- 链接列表删除节点C
- 链接列表删除
- 矢量与来自 STL 的列表 - 删除方法
- 运算符== 和列表::删除()