【问题标题】:boost::flat_set of iterators cannot mergeboost::flat_set 的迭代器不能合并
【发布时间】:2019-01-26 10:34:46
【问题描述】:

我正在尝试将boost::flat_set 用于我需要唯一的小型迭代器集。该代码无法编译,因为对 make_reverse_iterator 的调用不明确,但我不确定它是如何发生的。我试图将问题简化为 MWE:

#include <boost/container/flat_set.hpp>
#include <set>
#include <iostream>

using Set = std::set<int>;
using SetIt = Set::iterator;

struct Comparator {
    bool operator()(SetIt lhs, SetIt rhs) const {
        return &(*lhs) < &(*rhs);
    }
};


int main() {
    std::set<int> x;
    boost::container::flat_set<Set::iterator, Comparator> a;
    boost::container::flat_set<Set::iterator, Comparator> b;

    a.insert(x.insert(1).first);
    a.insert(x.insert(2).first);
    a.insert(x.insert(3).first);
    a.insert(x.insert(4).first);
    a.insert(x.insert(5).first);

    b.insert(x.insert(3).first);
    b.insert(x.insert(4).first);
    b.insert(x.insert(5).first);
    b.insert(x.insert(6).first);
    b.insert(x.insert(7).first);

    a.merge(b);

    for (auto v : a)
        std::cout << *v << '\n';
    return 0;
}

【问题讨论】:

    标签: c++ boost iterator c++17


    【解决方案1】:

    这个问题显然是fixed in Boost 1.67

    我在 fixed in Boost 1.66 上重现了错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-14
      • 2016-06-18
      • 1970-01-01
      • 2019-08-22
      • 2011-02-05
      相关资源
      最近更新 更多