简体   繁体   English

boost :: flat_set的迭代器无法合并

[英]boost::flat_set of iterators cannot merge

I'm trying to use boost::flat_set for small sets of iterators which I require to be unique. 我正在尝试将boost::flat_set用于我需要的小型迭代器集。 The code does not compile as there is an ambiguous call to make_reverse_iterator , but I'm not sure how it is happening. 由于对make_reverse_iterator调用不明确,代码无法编译,但我不确定它是如何发生的。 I've tried to reduce the problem to a MWE: 我试图将问题减少到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;
}

This problem is apparently fixed in Boost 1.67 . 这个问题显然已在Boost 1.67中修复

I reproduced the error on fixed in Boost 1.66 . 在Boost 1.66中修复了错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM