Boost logo

Boost :

Subject: Re: [boost] [Range] Range adaptor approach for temporary range lifetime issue
From: Michel Morin (mimomorin_at_[hidden])
Date: 2012-06-24 09:18:29


Neil Groves wrote:
> As a general idiom the use of lazily adapting upon the invocation of
> begin/end would mix two responsibilities. If one considers the complications
> involved with managing functor and predicate state being delayed until the
> invocation of begin/end it appears to be a considerably more complex
> solution. I do not perceive a compensating advantage for this approach. Of
> course, I may well be missing the advantage and invite correction.

But the lazy adaption is necessary to resolve the lifetime problem:

* To resolve the lifetime problem, each pipe operator
should move a temporary container.
* Since moving a container might invalidate iterators,
each range adaptors should be applied to the last moved container
(i.e. the moved container which is moved by the last pipe operator).
* We cannot distinguish the last pipe operator from other pipe operators.

So the only feasible timing for applying range adaptors is when
begin/end is (directly or indirectly) called.

Regards,
Michel


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