Subject: Re: [boost] [range] - Proposal to change the indexed range adaptor
From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2010-11-01 06:31:59
Den 31-10-2010 21:43, Neil Groves skrev:
> 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
> the index
> // and the original reference type of the underlying iterator/range.
> std::size i = item.first;
> const element_type& elem = item.second;
Your new version works well with foreach, but perhaps less so with
other iteration mathods.
Therefore I suggest that you add a new range instead of messing with the
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk