To my surprise this Concept-like assertion fails in RangeV3.
#include
#include
int main(){
It looks like there are some unexpected (to me) requirements need by ranges::copy
. So RangesV3 provides a drop in replacement ranges::back_inserter
that works.
However there are many other iterators in the standard that do not work for the same reason but to which there is no drop-in replacements, so it can get ugly.
For example, I had to adapt a new iterator to replace std::ostream_iterator
creating some artificial functions, including a default constructor:
template
struct ranges_ostream_iterator : std::ostream_iterator{
using std::ostream_iterator::ostream_iterator;
ranges_ostream_iterator() : std::ostream_iterator{std::cout}{} // I have to put something here
ranges_ostream_iterator& operator++(){std::ostream_iterator::operator++(); return *this;}
ranges_ostream_iterator& operator++(int){return operator++();}
using difference_type = int;
int operator-(ranges_ostream_iterator const&){return 0;}
};
With this, ranges::copy(first, last, ranges_ostream_iterator
work, whereas ranges::copy(first, last, std::ostream_iterator
doesn't.