boost::property_tree::ptree::迭代器定义运算符+;

boost::property_tree::ptree::迭代器定义运算符+;,boost,Boost,inerator始终支持运算符+,例如 const string s = "abcdef"; cout << *(s.begin() + 3);//output d 我知道我可以使用for循环来实现这一点。但我想知道是否有更优雅的方式来做到这一点?我通过以下方式实现了这一点: template <class InputIterator, class Distance> void advance (InputIterator& it, Distance n);

inerator始终支持运算符+,例如

const string s = "abcdef";
cout << *(s.begin() + 3);//output d
我知道我可以使用for循环来实现这一点。但我想知道是否有更优雅的方式来做到这一点?

我通过以下方式实现了这一点:

template <class InputIterator, class Distance>
  void advance (InputIterator& it, Distance n);
从文件(我的重点):“属性树库提供了一个数据结构,存储任意深度嵌套的值树,通过某个键在每一级建立索引。树的每个节点都存储自己的值,以及其子节点及其键的有序列表。树允许通过路径轻松访问其任何节点,路径是多个键的串联。“我想如果你开始将事物称为绝对或相对索引,你会失去相当多的灵活性。我必须这样做。
template <class InputIterator, class Distance>
  void advance (InputIterator& it, Distance n);
auto iter = p.begin();
advance(iter, 3);