Should range foreach be iterating over an implicit copy?
Steven Schveighoffer
schveiguy at yahoo.com
Thu May 17 10:23:22 PDT 2012
On Thu, 17 May 2012 11:42:04 -0400, Jonathan M Davis <jmdavisProg at gmx.com>
wrote:
> On Thursday, May 17, 2012 11:05:46 Steven Schveighoffer wrote:
>> Hm... proposal:
>>
>> foreach(e; ref r)
>> {
>> }
>>
>> equates to your desired code. Would this help?
>
> Or you could just do
>
> for(; !r.empty; r.popFront())
> {
> auto e = r.front;
> }
>
> I really don't think that that's a big deal. I don't think that the
> language
> change would be worth having yet another thing in the language to
> remember,
> particularly when it's so easy to just use for to do the job.
Probably true. The only one I'd see as being impossible to duplicate is:
foreach(ref e; ref r)
-Steve
More information about the Digitalmars-d
mailing list