2014-08-28 23:29 GMT+02:00 Robert Jones <robertgbjones@gmail.com>:
On 28 August 2014 22:22, Neil Groves <neil@grovescomputing.com> wrote:

The counting_range instance is a unnamed temporary,,,,

So the earlier lines are flawed too, just working by chance?

Yes, combinations of counting_range with reversed. But not because counting_range is a temporary.

I think the problem is counting_iterator returns a reference to an int it owns. Iterators shouldn't do that. 

Iterators should either: 
- return a reference to something they don't own, or
- return by value.

Regards,
Kris