Boost logo

Boost :

Subject: Re: [boost] [iterator] function_output_iterator constructed from a lambda function is not assignable
From: Peter Dimov (lists_at_[hidden])
Date: 2016-02-14 19:59:38


Mikhail Matrosov wrote:

> Can you suggest a workaround for this situation? Or maybe a way of
> improving function_output_iterator to overcome this issue?

One way of working around this limitation would be to define a class
optional_fn<F> that is like optional<F> but doesn't use F::operator= in its
assignment, always destroying the left side and copying instead. Its
operator() would forward to F::operator(). So you'd be able to construct a
function_output_iterator from make_optional_fn( []... ). This would also
make the iterator default constructible although this is not necessary for
output iterators. It is necessary for make_transform_iterator though, which
would also benefit from a similar treatment.

This should arguably be built into the iterators themselves; I think that
this has come up before on the list, but I don't remember the outcome of the
discussion.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk