c++ - boost::tokenizer_iterator 的问题——如何查看下一个迭代器?

标签 c++ boost iterator

代码是这样的

 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'
   }
 }

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

最佳答案

您始终可以只复制迭代器并递增拷贝。或者使用 boost::next

if(boost::next(iter) == end)
  cout << "...";

关于c++ - boost::tokenizer_iterator 的问题——如何查看下一个迭代器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13312991/

相关文章:

c++ - 从 catch 语句中使用 "go to"可以吗

c++ - 需要多个数独解决方案

c++ - For循环变慢

c++ - 用 c++11 等价物替换 boost::thread 和 boost::mutex 是否明智?

c++ - 使用 boost::locale 进行 Unicode 字符分类

c++ - boost_assert 一个参数类实现了某个方法

c++ - 如何在 C++ 中创建 web/wcf 服务客户端?

java - 常见迭代器错误的解释

python - 为我的自定义迭代器实现 iteritems 函数?

dataframe - 两个数据框中行的所有组合