我正在迭代 a boost interval_set<unsigned_int>
,并且我希望每个迭代器都是 a boost interval
,其值将使用upper
andlower
方法访问:
boost::icl::interval_set<unsigned int> outages;
// ...
// Insert intervals into the database
for(boost::icl::interval_set<unsigned int>::iterator it =
outages.begin(); it != outages.end(); it++){
DATA_ACQUISITION::InsertInterval(db, it->lower(),
it->upper())
}
但是我在方法lower
和upper
方法上都收到错误:Method ... could not be resolved,这表明迭代器根本没有指向 a interval
。
那么,我在这里真正迭代的是什么?如何迭代intervals
插入到interval
_set中?
编辑:添加 SSCCE:
#include <boost/icl/interval_set.hpp>
#include <iostream>
#include <vector>
int main() {
boost::icl::interval_set<unsigned int> outages;
for(unsigned int i=0; i<5; i++){
outages += boost::icl::discrete_interval<unsigned int>::closed(
(i*10), ((i*10) + 5));
}
for(boost::icl::interval_set<unsigned int>::iterator it =
outages.begin(); it != outages.end(); it++){
std::cout << it->lower() << boost::icl::upper(*it);
}
return 0;
}
附加信息:
- 我目前没有在链接器中添加任何库(直到现在,没有错误提示我需要它,并且还没有找到应该添加到 -l 的参数)
- 编译器 g++ 4.8.1
- 增强版:1.46