28 Aug
2014
28 Aug
'14
9:41 p.m.
On 28 August 2014 22:22, Neil Groves
The counting_range instance is a unnamed temporary, since the adaptors are applied to this temporary the adapted iterators may live beyond the lifetime of the source. If you where to add the line:
const auto& rng = counting_range(1, 5)
and then you did: print_it(rng | reversed | transformed(bind(doubled, _1)));
it should then work since there are no issues with chaining the adaptors since the iterators are always copied from the base range instances during the chaining process. One has to manage the lifetime of the source to ensure it lives beyond the lifetime of the iterators.
Actually that doesn't work, makes no difference! - Rob.