Subject: Re: [boost] [iterator] why isn't there a mapped_type iterator adaptor in boost?
From: Simon Richter (Simon.Richter_at_[hidden])
Date: 2010-05-16 10:14:52


Hi,

On Sun, May 16, 2010 at 03:50:11PM +0200, Christopher Schmidt wrote:

> > Is there much interest in using the library in this way? I'm happy to
> > implement this if there is.

> Yes, please. I would love to see a type-erased range and a type-erasing
> adaptor - exactly for the reason you pointed out.

I have a working range implementation, but I find it very difficult to write
an output iterator for use with std::copy, because the updated output iterator
is returned by value, and I cannot prove statically that the returned iterator
is indeed of the same type as the local one.

As a bit of a workaround,

vector<int> v1 = { 1, 2, 3 };
vector<int> v2;
output_iterator<int> o = back_inserter(v2);
o = copy(v1.begin(), v2.end(), o);

works, but the operator= is expensive and we lose all the optimization
potential from knowing the actual iterator type in the caller as well.

   Simon