gpt4 book ai didi

c++ - 如何使用 yaml-cpp 0.5.0 API 从列表中删除元素

转载 作者:太空宇宙 更新时间:2023-11-04 11:59:43 26 4
gpt4 key购买 nike

以下测试代码没有按预期从列表中删除元素:

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++ - 如何使用 yaml-cpp 0.5.0 API 从列表中删除元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14630516/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com