【发布时间】:2015-01-29 14:30:55
【问题描述】:
我正在迭代一个boost interval_set<unsigned_int>,我希望每个迭代器都是一个boost interval,其值将通过upper 和lower 方法访问:
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 方法中都收到错误:方法 ... 无法解析,这表明迭代器未指向 interval全部。
那么,我在这里真正迭代的是什么?如何迭代插入到interval_set 中的intervals?
编辑:添加 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
【问题讨论】:
-
我会重新安装/手动安装 boost。我已经使用 GCC 4.8.2 编译了 SSCCE,并从
wget http://sourceforge.net/projects/boost/files/boost/1.46.0/boost_1_46_0,1.tar.bz2(以及 1_47_1)提升。 -
@sehe 已重新安装 1_46_0,但与 Ubuntu 12.04 repo 的版本相比,仍然存在相同的问题。 it->lowers 抛出错误“方法 lower 无法解析”,boost::icl::upper(*it) 抛出“无效参数”,并建议作为候选者“boost:enable::if<:icl: :invercal>、bost::icl::inverval_traits::domain_type::type upper(const #0 &)',以及其他类似的选择,但不相关。这很奇怪,接下来我该尝试什么?
-
建议保持不变。您看到具有相同版本的不同来源是没有意义的。尝试打印增强版本:coliru.stacked-crooked.com/a/f7a2ee559e0cf008 或检查预处理源。检查另一个系统等(可能安装了冲突版本,例如
/usr/includevs/usr/local/include)。