Boost logo

Boost :

Subject: [boost] [iterator] reverse_iterator<counting_iterator<T>>
From: Arno Schödl (aschoedl_at_[hidden])
Date: 2010-04-13 04:26:10


boost::reverse_iterator::dereference() is

typename super_t::reference dereference() const { return *boost::prior(this->base()); }

boost::constant_iterator<T>::reference_type is T const&.

So reverse_iterator< constant_iterator<T> >::dereference returns a reference to a temporary variable. Not good.

I suggest removing the reference from boost::constant_iterator::reference_type, making it T. The rule would be that reference_type must only be a reference if the reference is pointing to some underlying container, not to the iterator itself.


Dr. Arno Schoedl · aschoedl_at_[hidden] 
Technical Director 
think-cell Software GmbH · Chausseestr. 8/E · 10115 Berlin, Germany · phone +49 30 666473-10 · toll-free (US) +1 800 891 8091
Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl · Amtsgericht Berlin-Charlottenburg, HRB 85229

Boost list run by bdawes at, gregod at, cpdaniel at, john at