Iterating over containers of immutable objects

Justin Johansson no at spam.com
Tue Jun 29 16:08:13 PDT 2010


Steven Schveighoffer wrote:
> On Tue, 29 Jun 2010 18:42:18 -0400, Justin Johansson <no at spam.com> wrote:
> 
>> Steven Schveighoffer wrote:
> 
>> There is another solution which requires introducing an extra virtual
>> method (and associated cost thereof) namely "hasNext" to the iterator
>> interface.  This allows pulling a single item (if it exists) out of
>> the iterator on demand.
> 
> Duh... I just thought of this too:
> 
> while(auto bar = iter.next())	// line 37
> {
>   ...
> }

Sorry that does not compile, dunno if it should I'm using
the latest D2.

test.d(37): expression expected, not 'auto'
test.d(37): found 'bar' when expecting ')'
test.d(37): found '=' instead of statement
test.d(41): unrecognized declaration

JJ


More information about the Digitalmars-d mailing list