How to iterate a boost property tree?(如何迭代提升属性树?)
问题描述
我知道正在接近 boost 属性树,并看到它是用于 c++ 编程的 boost 库的一个很好的特性.
I am know approaching to boost property tree and saw that it is a good feature of boost libs for c++ programming.
嗯,我有一个疑问?如何使用迭代器或类似方法迭代属性树?
Well, I have one doubt? how to iterate a property tree using iterators or similar?
在参考中只是一个浏览树的例子:
In reference there is just an example of browsing the tree through:
BOOST_FOREACH
但是没有别的了吗?类似于 stl 的容器之类的东西?这将是一个更好的解决方案,谈到代码质量......
But is there nothing more? Something like an stl-like container? It would be a better solution, speaking about code quality....
推荐答案
BOOST_FOREACH只是一种方便的迭代方式,可以通过iterator、begin()和end()来完成
BOOST_FOREACH is just a convenient way for iterating that can be done by iterator, begin() and end()
Your_tree_type::const_iterator end = tree.end();
for (your_tree_type::const_iterator it = tree.begin(); it != end; ++it)
...
从 C++11 开始就是:
And since C++11 it's:
for (auto& it: tree)
...
这篇关于如何迭代提升属性树?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何迭代提升属性树?


基础教程推荐
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- CString 到 char* 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16