Subject: Re: [boost] [range] - Proposal to change the indexed range adaptor
From: Neil Groves (neil_at_[hidden])
Date: 2010-10-31 16:43:42
On Sat, Oct 30, 2010 at 6:28 PM, Robert Jones <robertgbjones_at_[hidden]>wrote:
> On Sat, Oct 30, 2010 at 12:38 PM, Neil Groves <neil_at_[hidden]
> > I propose that a breaking change is made to the index range adaptor so
> > it returns a pair<original_reference_type, index_type>.
> Hi Neil
> Could you provide a use-case example, before and after.
Certainly. I should have thought to do this in the original email. Thank you
for taking the time to help me acquire information.
BOOST_FOREACH( auto item, rng | index )
// access to the index is not possible - doh :-(
// The return type of the dereferenced element from an index range
adaptor loses the index
const element_type& elem = item;
BOOST_FOREACH( auto item, rng | indexed )
// After my proposed modification, the return type becomes a pair of
// and the original reference type of the underlying iterator/range.
std::size i = item.first;
const element_type& elem = item.second;
> - Rob.
I hope this makes the motivation for the change clearer. My original design
does, of course, work if one writes the algorithm specifically to extract
the index directly from the iterator. This is unnecessarily limiting.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk