0

代码是这样的

 void buildIt(Object& o, Tokenizer::const_iterator begin, Tokenizer::const_iterator end){
   if(begin == end) return;
   else{
    string parent = *begin;
    bool hasChild = (begin+1) != end; //error: class booost::token_iterator<...> has no member named 'advance'
   }
 }

如何在不移动的情况下检查下一个迭代器是否有效?

4

2 回答 2

1
for (Tokenizer::const_iterator i = begin; i!= end; ++i) {
    ...
}
于 2012-11-09T19:09:00.597 回答
1

您总是可以只复制迭代器并增加副本。或使用boost::next.

if(boost::next(iter) == end)
  cout << "...";
于 2012-11-09T19:20:26.870 回答