|
Boost : |
Subject: Re: [boost] [Range] Range adaptor approach for temporary range lifetime issue
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2012-06-23 05:13:58
By the way, my first thought when I encountered this problem
is that C++11 ought to have specified the range-based for loop
in such a way that the lifetime of temporaries in the range
expression is extended for the duration of the loop.
Does anyone share this opinion? Would there be any downsides
to this?
It is also interesting to note that boost::for_each together
with a lambda - a from to which any range-based for loop can
easily be converted - does not suffer from this problem. I think
this corroborates the fact that the range-base for loop is
suboptimally specified in the standard - after all the range-
based for loop was meant to replace things like boost::for_each.
Regards,
Nate
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk