代码之家  ›  专栏  ›  技术社区  ›  Svalorzen

boost::一组迭代器不能合并

  •  1
  • Svalorzen  · 技术社区  · 7 年前

    我想用 boost::flat_set 对于我要求唯一的小迭代器集。代码无法编译,因为对 make_reverse_iterator ,但我不知道是怎么回事。我试着把问题降低到最低限度:

    #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;
    }
    
    1 回复  |  直到 7 年前
        1
  •  3
  •   sehe    7 年前

    这个问题显然是 fixed in Boost 1.67 .

    我把错误转载到 fixed in Boost 1.66 .