#include <vector>
#include <iostream>
#include <range/v3/all.hpp>
int main()
{
auto coll = std::vector{ 1, 2, 3 };
ranges::copy(
coll,
ranges::ostream_iterator<int>{ std::cout, ", " }
); // ok
ranges::copy(
coll,
std::ostream_iterator<int>{ std::cout, ", " }
); // error
}
该问题显示在上面的代码中。我使用range-v3-0.3.7。
对我来说,通用算法copy
不应该关心目标迭代器类型,只要它满足输出迭代器的要求。
如果是这样,为什么范围的算法与 std 的迭代器不兼容?